![]() |
Cockatrice 2026-09-01-Development-3.1.0-beta.10
A virtual tabletop for multiplayer card games
|
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) | |
| LazyPropertiesHash & | operator= (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. | |
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.
| LazyPropertiesHash::LazyPropertiesHash | ( | ) |
Default constructor.
|
explicit |
Creates an unmaterialized LazyPropertiesHash.
| blob | The pre-serialized blob |
|
explicit |
Creates an already-materialized LazyPropertiesHash.
| properties | The properties |
| LazyPropertiesHash::LazyPropertiesHash | ( | const LazyPropertiesHash & | other | ) |
|
private |
Materializes properties from blob if not already done. Clears blob afterward. Safe to call from const getters (members are mutable).
| const QHash< QString, QString > & LazyPropertiesHash::getProperties | ( | ) | const |
Gets a view of the materialized properties hash.
| bool LazyPropertiesHash::insert | ( | const QString & | key, |
| const QString & | value ) |
Inserts a value into the materialized properties hash.
| key | The key |
| value | The value to insert |
| LazyPropertiesHash & LazyPropertiesHash::operator= | ( | const LazyPropertiesHash & | other | ) |
| QString LazyPropertiesHash::value | ( | const QString & | key | ) | const |
Gets the value from the materialized properties hash.
| key | The key |
|
mutableprivate |
Serialized properties (load form).
|
mutableprivate |
Whether propertiesCache is valid.
|
mutableprivate |
Materialized properties (query form).
|
mutableprivate |
Guards lazy materialization.