class MetadataManager {
|
public:
|
/**
|
* Increments the usage counter of the active metadata and returns a RAII object, which contains the currently active
|
* metadata. When the RAII object goes out of scope it will call removeMetadataUser.
|
*/
|
ScopedCollectionMetadata getActiveMetadata();
|
|
/**
|
* Changes the active metadata and if there are current users of the current active metadata puts it on the
|
* _metadataInUse set.
|
*/
|
void setActiveMetadata(std::unique_ptr<CollectionMetadata> newActiveMetadata);
|
|
/**
|
* Decrements the usage counter of the specified metadata tracker and if that count is zero and the tracker is on the
|
* _metadataInUse set, removes it from there.
|
*/
|
void removeMetadataUsage(CollectionMetadataTracker* metadataTracker);
|
|
private:
|
struct CollectionMetadataTracker {
|
std::unique_ptr<CollectionMetadata> metadata;
|
uint32_t usageCounter;
|
};
|
|
friend class ScopedCollectionMetadata;
|
|
CollectionMetadataTracker _activeMetadata;
|
|
std::set<CollectionMetadataTracker> _metadataInUse;
|
};
|