Class DataManager
Defined in File data-manager.h
Nested Relationships
Nested Types
Class Documentation
-
class DataManager
Allows association of arbitrary ref-counted data with objects in a thread-safe manner.
Public Types
-
typedef uint64_t ObjectRef
-
typedef void *Key
-
typedef void (*ObjectEnumerationCallback)(ObjectRef object, Key key, ObjectData::Ptr data, void *userData)
Public Functions
-
DataManager()
-
~DataManager()
-
ObjectData::Ptr GetAssociatedDataRef(ObjectRef object, Key key)
Looks up data associated with a given object using the given key.
- Parameters
object -- The object that the data is associated with
key -- The lookup key (application-defined)
- Returns
A pointer to the previously set data, or null if none exists. Increments the ref count as it hands back the object, so the caller is responsible for calling Release() when they are through with the data.
-
void AssociateDataRefForObject(ObjectRef object, Key key, ObjectData::Ptr data, bool retain = false, ObjectRef *retainedObjectId = nullptr)
Associates a new reference to data with a given object using a given key.
Adding an entry that doesn't exist will result in the object's ref count increasing by 1. To remove an entry, pass in null data.
- Parameters
object -- The object to associate data with.
key -- The application-defined key that will be used to look up the associated data.
data -- The reference to the data to associate. If null, will clear the previous entry to null and decrement the ref count of the previous entry.
retain -- If data is nullptr, and retain is true, keep the associated object data around
-
void EnumerateObjectsWithKey(ObjectEnumerationCallback callback, Key key, void *userData)
-
void EnumerateObjectsWithKeys(ObjectEnumerationCallback callback, Key const *keys, size_t nKeys, void *userData)
version of EnumerateObjectsWithKey that will return objects with any of the keys listed in keys
-
void VisitAll(ObjectVisitor *visitor, void *key) const
Visit all objects in the manager that match key.
- Parameters
visitor --
key --
-
void Clear()
Clears the content of the data manager.
-
struct KeyedObjectData
-
typedef uint64_t ObjectRef