Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
lazy_properties_hash.h
Go to the documentation of this file.
1#ifndef COCKATRICE_LAZY_PROPERTIES_HASH_H
2#define COCKATRICE_LAZY_PROPERTIES_HASH_H
3
4#include <QByteArray>
5#include <QHash>
6#include <QMutex>
7#include <QString>
8
19{
20
21 mutable QByteArray blob;
23 mutable QMutex propertiesMutex;
24 mutable bool isMaterialized = false;
25
30 void ensureMaterialized() const;
31
32public:
37
42 explicit LazyPropertiesHash(const QByteArray &blob);
43
49
50 // Override copy constructor and copy-assignment because mutex isn't copiable
53
59 QString value(const QString &key) const;
60
67 bool insert(const QString &key, const QString &value);
68
74};
75
76#endif // COCKATRICE_LAZY_PROPERTIES_HASH_H
LazyPropertiesHash()
Default constructor.
Definition lazy_properties_hash.cpp:7
bool isMaterialized
Whether propertiesCache is valid.
Definition lazy_properties_hash.h:24
const QHash< QString, QString > & getProperties() const
Gets a view of the materialized properties hash.
Definition lazy_properties_hash.cpp:93
LazyPropertiesHash & operator=(const LazyPropertiesHash &other)
Definition lazy_properties_hash.cpp:35
QByteArray blob
Serialized properties (load form).
Definition lazy_properties_hash.h:21
QString value(const QString &key) const
Gets the value from the materialized properties hash.
Definition lazy_properties_hash.cpp:75
QMutex propertiesMutex
Guards lazy materialization.
Definition lazy_properties_hash.h:23
void ensureMaterialized() const
Materializes properties from blob if not already done. Clears blob afterward. Safe to call from const...
Definition lazy_properties_hash.cpp:56
QHash< QString, QString > properties
Materialized properties (query form).
Definition lazy_properties_hash.h:22
bool insert(const QString &key, const QString &value)
Inserts a value into the materialized properties hash.
Definition lazy_properties_hash.cpp:81
Definition mana_curve_category_widget.h:11