|
VR-Engage
2.3
|
The DtAttribute class provides a flexible system for storing data to be shared between various app systems and components. It supports type-safe access and thread-safe change notifications. Attributes are organized in a heirarchical tree structure. Attribute are identified by names, which must be unique within each node.
#include <attribute.h>
Classes | |
| struct | CallbacksForThread |
| struct | Stats |
Public Types | |
| enum | Trace { OFF , SET , CHANGE , GET , LOOKUP } |
| using | DumpItem = std::pair<DtAttributeHandle, std::list<std::string>> |
| using | DumpTable = std::list<DumpItem> |
Public Member Functions | |
| virtual | ~DtAttribute () |
| DtAttributeHandle | handle () |
| const DtAttributeHandle | handle () const |
| operator DtAttributeHandle () | |
| operator const DtAttributeHandle () const | |
| virtual const std::string & | name () const |
| virtual std::string | path () const |
| bool | addAlias (DtAttributeHandle alias) const |
| bool | removeAlias (DtAttributeHandle alias) const |
| const std::string & | type () const |
| template<typename T> | |
| bool | isType () const |
| bool | isType (const std::string &type) const |
| bool | isSet () const |
| bool | await (bool silent=false, bool assert=false, double timeout=3.0) const |
| bool | await (std::function< bool(const DtAttributeHandle)> condition, bool silent=false, bool assert=false, double timeout=3.0) const |
| template<typename T> | |
| const T | get () const |
| template<typename T> | |
| T | getOr (T orValue) const |
| template<typename T> | |
| bool | set (const T &value) |
| template<typename T> | |
| bool | setIfNot (const T &defaultValue) |
| template<typename T> | |
| bool | setType () |
| template<typename RET_T, typename T> | |
| RET_T | read (std::function< RET_T(const T &value)> readFunc) const |
| template<typename T> | |
| void | modifyFast (std::function< bool(T &value)> modifyFunc) |
| template<typename T> | |
| bool | modify (std::function< void(T &value)> modifyFunc) |
| template<typename T> | |
| const T | getAttribute (const std::string &attribute) const |
| template<typename T> | |
| T | getAttributeOr (const std::string &attribute, T orValue) const |
| template<typename T> | |
| bool | setAttribute (const std::string &attribute, const T &newValue) |
| std::string | getAsString () const |
| bool | setFromString (const std::string &newValue) |
| template<typename T> | |
| const T | previousValue () const |
| bool | unset () const |
| bool | unsetRecursive () |
| void | setPersistence (bool persistent) |
| void | setPersistenceRecursive (bool persistent) |
| bool | isPersistent () const |
| bool | hasAttribute (const std::string &name) const |
| bool | contains (const DtAttributeHandle &attr) const |
| bool | containedBy (const DtAttributeHandle &attr) const |
| DtAttributeHandle | attribute (const std::string &name) |
| const DtAttributeHandle | attribute (const std::string &name) const |
| DtAttributeHandle | parent () |
| const DtAttributeHandle | parent () const |
| DtAttributeHandle | first () |
| const DtAttributeHandle | first () const |
| void | forEach (const std::function< void(DtAttributeHandle)> &forEachFun) |
| void | forEach (const std::function< void(const DtAttributeHandle)> &forEachFun) const |
| bool | isRoot () const |
| const void * | raw () const |
| bool | isLocked () const |
| void | addCallback (const DtAttributeCallbackBase &callback) |
| void | removeCallback (const DtAttributeCallbackBase &callback) |
| unsigned int | handleCount () const |
| const Stats & | stats () const |
Static Public Member Functions | |
| static DtAttributeHandle | Root () |
| static void | registerCallbackThread () |
| static void | unregisterCallbackThread () |
| static void | callbackDispatchTick () |
| static void | recursiveDumpToTable (const DtAttributeHandle attrToDump, DumpTable &output, int depth=0) |
| static void | quickDump (const DtAttributeHandle, bool includeValues=false, int depth=0) |
| static void | QueueTrace (DtAttributeHandle attribute, Trace trace) |
| static std::pair< DtAttributeHandle, Trace > | QueuedTrace () |
| static void | CancelQueuedTrace () |
| static void | TidyUp () |
Protected Types | |
| using | Ptr = std::shared_ptr<DtAttribute> |
| using | Ref = std::weak_ptr<DtAttribute> |
| using | Map = std::map<std::string, std::pair<Ptr, Ref>> |
| using | DataPtr = std::shared_ptr<DtAttributeData> |
| using | CallbackList = std::list<const DtAttributeCallbackBase*> |
| using | Mutex = tbb::spin_rw_mutex |
| using | MutexLock = tbb::spin_rw_mutex::scoped_lock |
| using | CallbackThreadMap = std::map<unsigned int, CallbacksForThread> |
Protected Member Functions | |
| DtAttribute () | |
| DtAttribute (const std::string &name, const Ptr &parent) | |
| const Ptr | self () const |
| Ptr | self () |
| bool | lock (unsigned int key) |
| bool | unlock (unsigned int key) |
| const Ptr | pFirst () const |
| Ptr | pFirst () |
| const Ptr | pNext (const Ptr ¤t) const |
| Ptr | pNext (const Ptr ¤t) |
| DtAttributeHandle | handleFor (const Ptr &child, const Map::const_iterator &) const |
| Ptr | _nextValid (Map::iterator &fromIt) const |
| DtAttributeHandle | nextAfter (const DtAttributeHandle &ref) |
| const DtAttributeHandle | nextAfter (const DtAttributeHandle &ref) const |
| void | forEach (const std::function< void(Ptr)> &forEachFun) |
| void | forEach (const std::function< void(const Ptr)> &forEachFun) const |
| Ptr | find (const std::string &path, bool orCreate=false, std::string *foundAs=nullptr, Ptr *foundIn=nullptr) |
| const Ptr | find (const std::string &path, bool orCreate=false, std::string *foundAs=nullptr, Ptr *foundIn=nullptr) const |
| Ptr | addAttribute (const std::string &name, bool &aliasExists) |
| const Ptr | addAttribute (const std::string &name, bool &aliasExists) const |
| const std::string & | _type () const |
| template<typename T> | |
| bool | _isType () const |
| template<typename T> | |
| void | _assertType () const |
| bool | _isType (const std::string &type) const |
| bool | _isSet () const |
| bool | _isLocked () const |
| template<typename T> | |
| void | _createData () const |
| template<typename T> | |
| void | validateData (MutexLock &lock) const |
| void | invokePendingCallbacksRecursive () |
| void | invokePendingCallbacks () |
| void | invokeCallbacks (const Ptr &changed, const unsigned int threadId) |
| void | valueChanged () |
| bool | _lockCheck (unsigned int callerKey=0) const |
| bool | recursiveLock (unsigned int callerKey) |
| bool | recursiveUnlock (unsigned int callerKey) |
| void | doTraceIf (Trace which) const |
| void | incHandleCount () |
| void | decHandleCount () |
| void | cleanTheMap () |
Static Protected Member Functions | |
| static Ptr | create (const std::string &name, const Ptr &parent) |
| static std::unordered_map< unsigned int, bool > | callbackThreadIds () |
| static unsigned int | callbackThreadIdForThread (const unsigned int threadId) |
| static void | callbacksStartedOnThread (const unsigned int threadId) |
| static void | callbacksFinishedOnThread (const unsigned int threadId) |
| static bool | callbacksRunningOnThread (const unsigned int threadId) |
| static void | needsTidying (DtAttribute::Ptr dirty) |
Protected Attributes | |
| std::string | myName |
| DataPtr | myData |
| bool | myExplicitType |
| Mutex | myValueMutex |
| Mutex | myMapMutex |
| Mutex | myCallbackMutex |
| CallbackThreadMap | myChangeCallbacks |
| Stats | myStats |
| Ref | mySelf |
| Ptr | mySelfInit |
| Ptr | myParent |
| Map | myAttributes |
| Map::iterator | myItr |
| unsigned int | myWriteKey |
| std::atomic< unsigned int > | myHandleCount = 0 |
Static Protected Attributes | |
| static Mutex | TheCallbackThreadMapMutex |
| static std::unordered_map< unsigned int, bool > | TheCallbackThreadMap |
| static std::pair< Ref, Trace > | TheQueuedTrace |
| static std::pair< Ref, std::string > | TheLastTrace |
| static Mutex | TheTraceMutex |
| static std::atomic< bool > | TheTraceQueuedFlag |
| static Mutex | TheTidyMutex |
| static std::map< void *, Ref > | TheAttributesNeedTidying |
Friends | |
| class | DtAttributeHandle |
| using makVre::DtAttribute::DumpItem = std::pair<DtAttributeHandle, std::list<std::string>> |
Recursively dumps the attribute hierarchy to a table.
| depth | The current depth in the hierarchy |
| using makVre::DtAttribute::DumpTable = std::list<DumpItem> |
|
protected |
Shared pointer type for attributes.
|
protected |
Weak pointer type for attributes.
|
protected |
Map type for storing child attributes.
|
protected |
Shared pointer type for attribute data storage.
|
protected |
Ordered list of raw callback pointers for a single thread.
|
protected |
Mutex type used for thread-safe attribute access.
|
protected |
|
protected |
Map of per-thread callback state, keyed by thread ID.
Trace level for diagnostic attribute access logging.
When a trace is queued via QueueTrace(), the attribute system will trigger a debug break the next time the specified access type occurs on the target attribute.
| Enumerator | |
|---|---|
| OFF | Tracing disabled. |
| SET | Trace on the next value set. |
| CHANGE | Trace on the next value change. |
| GET | Trace on the next value get. |
| LOOKUP | Trace on the next attribute lookup. |
|
virtual |
Virtual destructor.
|
protected |
Default constructor.
|
protected |
|
static |
Returns a reference to the root attribute.
References DtAttributeHandle.
| DtAttributeHandle makVre::DtAttribute::handle | ( | ) |
Returns the handle for this attribute.
References DtAttributeHandle.
| const DtAttributeHandle makVre::DtAttribute::handle | ( | ) | const |
Returns the const handle for this attribute.
References DtAttributeHandle.
| makVre::DtAttribute::operator DtAttributeHandle | ( | ) |
Conversion operator to DtAttributeHandle.
References DtAttributeHandle.
| makVre::DtAttribute::operator const DtAttributeHandle | ( | ) | const |
Conversion operator to const DtAttributeHandle.
References DtAttributeHandle.
|
virtual |
Returns the name associated with this attribute.
Referenced by addAttribute(), addAttribute(), attribute(), attribute(), create(), DtAttribute(), and hasAttribute().
|
virtual |
| bool makVre::DtAttribute::addAlias | ( | DtAttributeHandle | alias | ) | const |
Assigns an alias path for this attribute.
Aliases allows the same attribute to be accessed using alternate paths.
Methods such as parent() and path() that reference the parent attribute will always reflect the original parent.
| alias | A handle to the attribute path that should be used as the alias path. |
The given handle must be assigned a path. The attribute at this handle must not be set, it must not be readonly, it must have no other handles, and it cannot be Root().
If the alias handle meets the criteria, the alias path will be created.
References DtAttributeHandle.
| bool makVre::DtAttribute::removeAlias | ( | DtAttributeHandle | alias | ) | const |
Removes an alias path for this attribute.
| alias | A handle to the alias attribute path to be removed. |
The alias handle must be an alias currently assigned to this attribute.
If the alias handle meets the criteria, the alias path will be removed.
References DtAttributeHandle.
| const std::string & makVre::DtAttribute::type | ( | ) | const |
Returns the type of this attribute.
| bool makVre::DtAttribute::isType | ( | ) | const |
Checks if the attribute is of the specified type.
| bool makVre::DtAttribute::isType | ( | const std::string & | type | ) | const |
Checks if the attribute is of the specified type by name.
| type | The type name to check against |
References type().
| bool makVre::DtAttribute::isSet | ( | ) | const |
Checks if the attribute value is undefined.
| bool makVre::DtAttribute::await | ( | bool | silent = false, |
| bool | assert = false, | ||
| double | timeout = 3.0 ) const |
Blocks execution on this thread until this attribute value is defined.
| timeout | Seconds to wait; optional, default 3.0 |
| silent | If set true, no error is logged on timeout; optional, default false |
| assert | If true, breaks with assert on failure, else just logs warning; optional, default false |
Execution will continue once a value is set, or timeout time elapses. If wait times out, an error will be logged. This method returns immediately if the value of this attribute is already set.
Do not use this unless the value will be set by another thread.
| bool makVre::DtAttribute::await | ( | std::function< bool(const DtAttributeHandle)> | condition, |
| bool | silent = false, | ||
| bool | assert = false, | ||
| double | timeout = 3.0 ) const |
Blocks execution on this thread until the condition is satisfied.
| condition | Callable to test required condition to continue |
| timeout | Seconds to wait; optional, default 3.0 |
| silent | If set true, no error is logged on timeout; optional, default false |
| assert | If true, breaks with assert on failure, else just logs warning; optional, default false |
Execution will continue once condition returns true, or timeout time elapses. If wait times out, an error will be logged.
Condition is a callable that receives this attribute as an argument, and must return true or false.
Do not use this unless the condition can be met by action from another thread.
References DtAttributeHandle.
| const T makVre::DtAttribute::get | ( | ) | const |
Gets the value of the attribute.
| T makVre::DtAttribute::getOr | ( | T | orValue | ) | const |
Gets the value of the attribute or a default value if undefined.
| orValue | The default value to return if the attribute is undefined |
| bool makVre::DtAttribute::set | ( | const T & | value | ) |
Sets the value of the attribute.
If the new value differs from existing, change callbacks will be invoked.
| value | The new value to set |
| bool makVre::DtAttribute::setIfNot | ( | const T & | defaultValue | ) |
Sets the value of the attribute only if it is currently undefined.
| defaultValue | The default value to set if the attribute is undefined |
| bool makVre::DtAttribute::setType | ( | ) |
Establish the type of the attribute if value attribute is not yet set.
Will zero-initialize the attribute value.
| RET_T makVre::DtAttribute::read | ( | std::function< RET_T(const T &value)> | readFunc | ) | const |
Reads the value of the attribute using a callback.
Alternative to get method that allows reading from large or complex data types without the overhead of copying the data, or when it is necessary to maintain a read lock on the attribute value for multi-step operations, e.g. reading a raw pointer, null-checking, then dereferencing to invoke a method.
| RET_T | Return type passed back from the read callback |
| readFunc | Callback that receives a const reference to the typed value |
| void makVre::DtAttribute::modifyFast | ( | std::function< bool(T &value)> | modifyFunc | ) |
Modifies the attribute value in-place using a callback.
Calls modifyFunc with a direct reference to the stored value. If the callback returns true, change callbacks are triggered without performing a before/after copy comparison, making this faster than modify() when the caller can determine whether the value actually changed.
| T | The type of the attribute value. |
| modifyFunc | Callback that receives a mutable reference to the value and returns true if the value was changed, false if it was not. |
| bool makVre::DtAttribute::modify | ( | std::function< void(T &value)> | modifyFunc | ) |
Modifies the attribute value in-place using a callback, with change detection.
Calls modifyFunc with a direct reference to the stored value, then compares the before and after state to determine if the value changed. Change callbacks are triggered only if the value actually changed.
| T | The type of the attribute value. |
| modifyFunc | Callback that receives a mutable reference to the value. |
| const T makVre::DtAttribute::getAttribute | ( | const std::string & | attribute | ) | const |
Gets the value of a child attribute.
Calls /ref get<T>() on the child attribute identified by attribute. This is a convenience method directly equivalent to [attribute]->get<T>()
| attribute | The name of the child attribute |
References attribute().
| T makVre::DtAttribute::getAttributeOr | ( | const std::string & | attribute, |
| T | orValue ) const |
Gets the value of a child attribute or a default value if undefined.
Calls /ref getOr<T>() on the child attribute identified by attribute. This is a convenience method directly equivalent to [attribute]->getOr<T>(orValue)
| attribute | The name of the child attribute |
| orValue | The default value to return if the attribute is undefined |
References attribute().
| bool makVre::DtAttribute::setAttribute | ( | const std::string & | attribute, |
| const T & | newValue ) |
Sets the value of a child attribute.
If the new value differs from existing, change callbacks will be invoked.
| attribute | The name of the child attribute |
| newValue | The new value to set |
References attribute().
| std::string makVre::DtAttribute::getAsString | ( | ) | const |
Gets string representation of the attribute value.
| bool makVre::DtAttribute::setFromString | ( | const std::string & | newValue | ) |
Sets the attribute value from a string representation.
If the new value differs from existing, change callbacks will be invoked.
| newValue | String representation of the new value |
| const T makVre::DtAttribute::previousValue | ( | ) | const |
Gets the previous value of the attribute before the last change.
| bool makVre::DtAttribute::unset | ( | ) | const |
Unsets the attribute value.
Value is returned to an undefined, typeless state
| bool makVre::DtAttribute::unsetRecursive | ( | ) |
Unsets this attribute and all child attributes, recursively.
| void makVre::DtAttribute::setPersistence | ( | bool | persistent | ) |
Set whether this attribute exists w/o handles assigned.
A persistent attribute will continue to exist in the attribute tree for the lifetime of the application. A non-persistent attribute will be deleted as soon as no handles are assigned to it. The default condition for attributes is persistent.
| persistent | Set true for persistent, false for non-persistent |
| void makVre::DtAttribute::setPersistenceRecursive | ( | bool | persistent | ) |
Sets the persistence of this attribute and all child attributes.
| persistent | Set true for persistent, false for non-persistent |
| bool makVre::DtAttribute::isPersistent | ( | ) | const |
Check the persistence state of this attribute.
| bool makVre::DtAttribute::hasAttribute | ( | const std::string & | name | ) | const |
Checks if a child attribute exists.
References name().
| bool makVre::DtAttribute::contains | ( | const DtAttributeHandle & | attr | ) | const |
Checks if the given attribute is a direct or indirect child of this attribute.
Recursively searches the subtree rooted at this attribute to determine if attr is a descendant.
| attr | The attribute handle to search for. |
attr is a descendant of this attribute, false otherwise. References DtAttributeHandle.
| bool makVre::DtAttribute::containedBy | ( | const DtAttributeHandle & | attr | ) | const |
Checks if this attribute is a direct or indirect child of the given attribute.
Walks up the parent chain from this attribute to determine if attr is an ancestor.
| attr | The attribute handle to test as a potential ancestor. |
attr, false otherwise. References DtAttributeHandle.
| DtAttributeHandle makVre::DtAttribute::attribute | ( | const std::string & | name | ) |
Gets a handle to a child attribute.
| name | The name of the child attribute. Name may be a path to child subattributes in format "ChildName.GrandChild.GreatGrandChild" |
References DtAttributeHandle, and name().
Referenced by getAttribute(), getAttributeOr(), QueueTrace(), and setAttribute().
| const DtAttributeHandle makVre::DtAttribute::attribute | ( | const std::string & | name | ) | const |
Const version of attribute(const std::string&)
References DtAttributeHandle, and name().
| DtAttributeHandle makVre::DtAttribute::parent | ( | ) |
Gets a handle to the parent attribute.
References DtAttributeHandle.
Referenced by create(), and DtAttribute().
| const DtAttributeHandle makVre::DtAttribute::parent | ( | ) | const |
Gets a const handle to the parent attribute.
References DtAttributeHandle.
| DtAttributeHandle makVre::DtAttribute::first | ( | ) |
Gets a handle to the first child attribute.
References DtAttributeHandle.
| const DtAttributeHandle makVre::DtAttribute::first | ( | ) | const |
Gets a const handle to the first child attribute.
References DtAttributeHandle.
| void makVre::DtAttribute::forEach | ( | const std::function< void(DtAttributeHandle)> & | forEachFun | ) |
Calls the given function for each immediate child attribute.
The child map is locked only per-entry so callbacks may safely access other attributes without deadlocking.
| forEachFun | Function to call with a handle to each child attribute. |
References DtAttributeHandle.
| void makVre::DtAttribute::forEach | ( | const std::function< void(const DtAttributeHandle)> & | forEachFun | ) | const |
Const version of forEach(std::function<void(DtAttributeHandle)>)
References DtAttributeHandle.
| bool makVre::DtAttribute::isRoot | ( | ) | const |
Checks if this attribute is the root attribute.
| const void * makVre::DtAttribute::raw | ( | ) | const |
Gets the raw data pointer.
| bool makVre::DtAttribute::isLocked | ( | ) | const |
Checks if the attribute is write-locked.
| void makVre::DtAttribute::addCallback | ( | const DtAttributeCallbackBase & | callback | ) |
Create a temporary write-lock on this attribute.
Creates a write-blocking mutex lock that will block any other thread attempting to change the value. Use sparingly when necessary to assure value does not change in critical use section, e.g. when checking and then dereferencing a raw pointer value. Use with caution, overuse will harm app performance.
Adds a change callback for this attribute
| callback | The callback to add |
| void makVre::DtAttribute::removeCallback | ( | const DtAttributeCallbackBase & | callback | ) |
Removes a change callback from this attribute.
| callback | The callback to remove |
|
static |
|
static |
|
static |
| unsigned int makVre::DtAttribute::handleCount | ( | ) | const |
Gets the number of handles currently assigned to this attribute.
|
static |
References DtAttributeHandle.
|
static |
References DtAttributeHandle.
|
inline |
|
static |
Queues a one-shot diagnostic trace for the specified attribute and access type.
The trace fires the next time the given access type occurs on attribute, then the queue is cleared. Only one trace can be queued at a time.
| attribute | The attribute to trace. |
| trace | The access type that should trigger the trace. |
References attribute(), and DtAttributeHandle.
|
static |
Returns the currently queued trace entry.
|
static |
Cancels any currently queued diagnostic trace.
|
static |
Perform any necessary cleanup of expired attribute entries in the attribute tree.
|
protected |
Gets a shared pointer to this attribute.
|
protected |
Locks write access to attribute value.
| key | Chosen key that will be required to unlock |
Referenced by validateData().
|
protected |
Unlocks write access.
| key | Must be the same key used to lock |
|
protected |
Get the first child attribute, excluding aliases.
Gets a shared pointer to the next sibling attribute after the current child, excluding aliases.
| current | Shared pointer to the current child attribute |
Non-const version of pNext(const Ptr&)
|
protected |
Generate a handle to the child attribute, with alias support.
Checks the parent of child, returns an alias handle if the parent is not this attribute.
| child | Shared pointer to the child attribute |
| it | Iterator to the map entry corresponding to the child attribute |
References DtAttributeHandle.
|
protected |
Get the next valid child entry.
Safety wrapper checks for expired entires.
| fromIt | Iterator to start searching from |
|
protected |
Gets a handle to the next child attribute after the reference child.
| ref | Handle to a reference child to start from |
References DtAttributeHandle.
|
protected |
Const version of nextAfter(const DtAttributeHandle&)
References DtAttributeHandle.
|
protected |
Calls the given function for each immediate child, excluding aliases.
Lower-overhead internal forEach using shared pointers instead of handles. Skips aliases.
| forEachFun | Function to call for each child. |
|
protected |
Const version of forEach(std::function<void(Ptr)>)
|
protected |
Recursive search for child attribute at path, relative to this.
Recursive child names in path are delimited by '.', e.g. find("childName.grandChildName.greatGrandChildName")
| path | Name or path of names of child attribute to find | |
| orCreate | If true, creates the attribute (and any intermediate path attributes) if not found; if false, returns null pointer when not found | |
| [out] | foundAs | Optional output for the alias name when the final path component resolves through an alias; unchanged otherwise. |
| [out] | foundIn | Optional output for the attribute containing the final alias entry; unchanged otherwise. |
References path().
|
protected |
Const overload of find().
| path | Name or path of names of child attribute to find. | |
| orCreate | If true, creates missing attributes along the path; if false, returns null when not found. | |
| [out] | foundAs | Optional output for the alias name when the final path component resolves through an alias; unchanged otherwise. |
| [out] | foundIn | Optional output for the attribute containing the final alias entry; unchanged otherwise. |
References path().
|
protected |
Creates and registers a new child attribute with the given name.
If an attribute with the same name already exists, the existing attribute is returned. Thread-safe.
| name | The name of the child attribute to create. | |
| [out] | aliasExists | Set to true if an existing entry is an alias, or false if it is not. Unchanged when a new attribute is created; initialize to false before calling. |
References name().
|
protected |
Const overload of addAttribute().
| name | The name of the child attribute to create. | |
| [out] | aliasExists | Set to true if an existing entry is an alias, or false if it is not. Unchanged when a new attribute is created; initialize to false before calling. |
References name().
|
protected |
|
protected |
Internal implementation of isType()
|
protected |
Throws an assertion if the attribute is not of type T.
|
protected |
|
protected |
Internal implementation of isSet()
|
protected |
Internal implementation of isLocked()
|
protected |
Creates data storage for the specified type.
|
protected |
Validates that the attribute data is of the specified type.
References lock().
|
protected |
Checks and dispatches pending change callbacks for this attribute and all descendants.
Calls invokePendingCallbacks() on this attribute, then recursively on all children. Typically called from multi-threaded tick functions to deliver deferred callback notifications on the correct thread.
|
protected |
Checks and dispatches pending change callbacks for the calling thread.
If this attribute's value was changed since the last dispatch for the calling thread, invokes all registered callbacks for that thread. Normally called by invokePendingCallbacksRecursive() or valueChanged().
|
protected |
Invokes all registered change callbacks.
|
protected |
Marks the value as changed and dispatches callbacks for the current thread.
Updates the changed flag for all registered threads and immediately invokes callbacks for the calling thread via checkPendingCallbacks().
|
staticprotected |
Gets the list of thread IDs that are known or registered to invoke callbacks.
|
staticprotected |
Gets the thread ID on which a callback from the current thread may be invoked.
This will return the current thread ID if the current thread is registered to invoke callbacks, else it will return the first registered callback thread, which should be the main thread.
|
staticprotected |
Record that the given thread is invoking callbacks.
|
staticprotected |
Record that the given thread is done invoking callbacks.
|
staticprotected |
Returns whether the given thread is invoking callbacks.
|
protected |
Checks if the attribute is locked against the given caller key.
| callerKey | Key to test against the lock owner; a matching key bypasses the lock |
|
protected |
Locks this attribute and all descendants recursively.
Uses best-effort semantics: continues even if a child is already locked by a different key, but returns false if any node could not be locked.
| callerKey | The key to use for locking |
|
protected |
Unlocks this attribute and all descendants whose lock key matches callerKey.
Nodes locked by a different key are left untouched.
| callerKey | The key used when locking |
|
protected |
Triggers a diagnostic debug break and logs trace context for this attribute.
Called internally when a queued trace condition is met. Outputs attribute path, value, and stack information to the log.
|
protected |
Increments the handle count for this attribute.
|
protected |
Decrements the handle count for this attribute.
|
protected |
Performs cleanup of expired child attribute entries in the map.
|
staticprotected |
Marks the attribute as needing tidying, adds to list to be cleaned up on the next call to TidyUp().
|
friend |
References DtAttributeHandle.
Referenced by addAlias(), attribute(), attribute(), await(), containedBy(), contains(), DtAttributeHandle, first(), first(), forEach(), forEach(), handle(), handle(), handleFor(), nextAfter(), nextAfter(), operator const DtAttributeHandle(), operator DtAttributeHandle(), parent(), parent(), QueueTrace(), quickDump(), recursiveDumpToTable(), removeAlias(), and Root().
|
protected |
The name of this attribute.
|
mutableprotected |
The data stored in this attribute.
|
mutableprotected |
Flag indicating if the type was explicitly set.
|
mutableprotected |
Attribute data value mutex for thread safety.
|
mutableprotected |
Sub-attribute map mutex for thread safety.
|
mutableprotected |
Value change callback mutex for thread safety.
|
protected |
List of change callbacks.
|
staticprotected |
|
staticprotected |
|
mutableprotected |
Statistics for this attribute.
Referenced by stats().
|
protected |
Weak reference to self.
|
protected |
Temporary shared pointer to self for initialization of mySelf.
|
protected |
Shared pointer to parent.
|
protected |
Iterator in parent's attribute map referring to this attribute.
|
protected |
Write permission key.
The currently queued one-shot diagnostic trace, if any.
|
staticprotected |
The most recent trace that was fired, stored for debugging purposes.
|
staticprotected |
Atmoic flag to avoid unnecessary mutex locks when no trace queued.
|
protected |
Count of active attribute handles to this attribute.
|
staticprotected |
Mutex protecting the static tidy list and related operations.
|
staticprotected |
List of attributes that need tidying up due to expired child entries.