Cockatrice 2026-09-01-Development-3.1.0-beta.10
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
LazyPropertiesHash Class Reference

A property map that can lazily deserialize blobs to avoid loading overhead. More...

#include <lazy_properties_hash.h>

Public Member Functions

 LazyPropertiesHash ()
 Default constructor.
 LazyPropertiesHash (const QByteArray &blob)
 Creates an unmaterialized LazyPropertiesHash.
 LazyPropertiesHash (const QHash< QString, QString > &properties)
 Creates an already-materialized LazyPropertiesHash.
 LazyPropertiesHash (const LazyPropertiesHash &other)
LazyPropertiesHashoperator= (const LazyPropertiesHash &other)
QString value (const QString &key) const
 Gets the value from the materialized properties hash.
bool insert (const QString &key, const QString &value)
 Inserts a value into the materialized properties hash.
const QHash< QString, QString > & getProperties () const
 Gets a view of the materialized properties hash.

Private Member Functions

void ensureMaterialized () const
 Materializes properties from blob if not already done. Clears blob afterward. Safe to call from const getters (members are mutable).

Private Attributes

QByteArray blob
 Serialized properties (load form).
QHash< QString, QString > properties
 Materialized properties (query form).
QMutex propertiesMutex
 Guards lazy materialization.
bool isMaterialized = false
 Whether propertiesCache is valid.

Detailed Description

A property map that can lazily deserialize blobs to avoid loading overhead.

Properties are stored as a pre-serialized blob (cheap to load), and the QString is materialized on the first query, so the database load avoids constructing thousands of QString per card.

Once the properties are materialized, it cannot be unmaterialized. If you want to reset the properties to an unmaterialized state, you should create a new LazyPropertiesHash.

Constructor & Destructor Documentation

◆ LazyPropertiesHash() [1/4]

LazyPropertiesHash::LazyPropertiesHash ( )

Default constructor.

Here is the caller graph for this function:

◆ LazyPropertiesHash() [2/4]

LazyPropertiesHash::LazyPropertiesHash ( const QByteArray & blob)
explicit

Creates an unmaterialized LazyPropertiesHash.

Parameters
blobThe pre-serialized blob

◆ LazyPropertiesHash() [3/4]

LazyPropertiesHash::LazyPropertiesHash ( const QHash< QString, QString > & properties)
explicit

Creates an already-materialized LazyPropertiesHash.

Parameters
propertiesThe properties

◆ LazyPropertiesHash() [4/4]

LazyPropertiesHash::LazyPropertiesHash ( const LazyPropertiesHash & other)
Here is the call graph for this function:

Member Function Documentation

◆ ensureMaterialized()

void LazyPropertiesHash::ensureMaterialized ( ) const
private

Materializes properties from blob if not already done. Clears blob afterward. Safe to call from const getters (members are mutable).

Here is the caller graph for this function:

◆ getProperties()

const QHash< QString, QString > & LazyPropertiesHash::getProperties ( ) const

Gets a view of the materialized properties hash.

Returns
The properties hash
Here is the call graph for this function:

◆ insert()

bool LazyPropertiesHash::insert ( const QString & key,
const QString & value )

Inserts a value into the materialized properties hash.

Parameters
keyThe key
valueThe value to insert
Returns
True if a new value was inserted; false if the new value is the same as the existing value
Here is the call graph for this function:

◆ operator=()

LazyPropertiesHash & LazyPropertiesHash::operator= ( const LazyPropertiesHash & other)
Here is the call graph for this function:

◆ value()

QString LazyPropertiesHash::value ( const QString & key) const

Gets the value from the materialized properties hash.

Parameters
keyThe key
Returns
The value, or an empty string if the key is not present
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ blob

QByteArray LazyPropertiesHash::blob
mutableprivate

Serialized properties (load form).

◆ isMaterialized

bool LazyPropertiesHash::isMaterialized = false
mutableprivate

Whether propertiesCache is valid.

◆ properties

QHash<QString, QString> LazyPropertiesHash::properties
mutableprivate

Materialized properties (query form).

◆ propertiesMutex

QMutex LazyPropertiesHash::propertiesMutex
mutableprivate

Guards lazy materialization.


The documentation for this class was generated from the following files: