Jamoma API
0.6.0.a19
|
We build a tree of TTNodes, and you can request a pointer for any TTNode, or add an observer to any TTNode, etc. More...
#include <TTNodeDirectory.h>
Public Member Functions | |
TTNodeDirectory (TTSymbol aName) | |
Constructor. | |
virtual | ~TTNodeDirectory () |
Destructor. | |
TTErr | init () |
Initialize the TTNodeDirectory. | |
TTErr | setName (TTSymbol aname) |
Set the name of the TTNodeDirectory. More... | |
TTSymbol | getName () |
Get the name of the TTNodeDirectory. | |
TTNodePtr | getRoot () |
Get the root of the TTNodeDirectory. | |
TTHashPtr | getDirectory () |
Get the directory of the TTNodeDirectory. | |
TTErr | getTTNode (const char *anAddress, TTNodePtr *returnedTTNode) |
Given an address, return a pointer to a TTNode. More... | |
TTErr | getAlias (TTAddress anAddress, TTAddress &returnedAlias) |
Given an address, return an alias if exists. More... | |
TTErr | replaceAlias (TTAddress &anAddress) |
Given an address with alias, return an address with no alias if exists. More... | |
TTErr | fillAddressItem (TTAddressItemPtr anAddressItem, TTAddress startAddress=kTTAdrsRoot) |
fill an address item using the TTNodeDirectory from an address More... | |
TTErr | Lookup (TTAddress anAddress, TTList &returnedTTNodes, TTNodePtr *firstReturnedTTNode) |
Find TTNodes by address. More... | |
TTErr | LookFor (TTListPtr whereToSearch, TTBoolean(*testFunction)(TTNodePtr node, TTPtr args), void *argument, TTList &returnedTTNodes, TTNodePtr *firstReturnedTTNode, TTUInt8 depthLimit=0, TTBoolean(*comparisonFunction)(TTValue &v1, TTValue &v2)=NULL) |
Find TTNodes by testing each TTNodes below an address. More... | |
TTErr | IsThere (TTListPtr whereToSearch, TTBoolean(*testFunction)(TTNodePtr node, void *args), void *argument, bool *isThere, TTNodePtr *firstTTNode) |
Is there is one TTNode or more that respect a test below an address. More... | |
TTErr | TTNodeCreate (TTAddress &anAddress, TTObject &newObject, void *aContext, TTNodePtr *returnedTTNode, TTBoolean *nodeCreated) |
Create a new TTNode, at the given location in the tree. More... | |
TTErr | TTNodeRemove (TTAddress &anAddress) |
Remove a TTNodefrom the directory. More... | |
TTErr | AliasCreate (TTAddress alias, TTAddress anAddress) |
Create an alias address. More... | |
TTErr | AliasRemove (TTAddress alias) |
Create an alias address. More... | |
TTErr | addObserverForNotifications (TTAddress anAddress, TTObject &anObserver, TTInt8 maxDepthDifference=-1) |
Add a TTCallback as a life cycle observer of all nodes below this one. More... | |
TTErr | removeObserverForNotifications (TTAddress anAddress, TTObject &anObserver) |
Remove a TTCallback as a life cycle observer of all nodes below this one. More... | |
TTErr | notifyObservers (TTAddress anAddress, TTNodePtr aNode, TTAddressNotificationFlag flag) |
Notify life cycle observers that something appends below this TTNode. More... | |
We build a tree of TTNodes, and you can request a pointer for any TTNode, or add an observer to any TTNode, etc.
Every time we create a TTNode (or a string passed to something somewhere?) then this gets added to the tree. If a TTNode is specified, such as /degrade~/audio/mute, and we assume degrade~ has been added to the tree but 'audio' hasn't, then 'audio' is added followed by adding 'mute', so that the tree is properly completed.
When a TTNode is requested, the tree is traversed to find the pointer for the TTNode. After the traversal (assuming no wildcards) the pointer is returned and also stored in a hash table so that future requests for that TTNode are faster.
The case of wildcards is handled, because a request is cached (keyed on the request), and the value is a linked list of all of the matches.
Definition at line 54 of file TTNodeDirectory.h.
TTErr TTNodeDirectory::addObserverForNotifications | ( | TTAddress | anAddress, |
TTObject & | anObserver, | ||
TTInt8 | maxDepthDifference = -1 |
||
) |
Add a TTCallback as a life cycle observer of all nodes below this one.
anAddress | an address to observe |
observer | a TTCallback object to add |
maxDepthDifference | precise the max depth difference to filter nodes which are below this limit |
Definition at line 590 of file TTNodeDirectory.cpp.
References TTHash::append(), TTValue::append(), kTTErrNone, kTTErrValueNotFound, TTHash::lookup(), and TTAddress::normalize().
Create an alias address.
alias | The alias address (absolute) |
anAddress | The address for which you wish to create an alias. |
Definition at line 342 of file TTNodeDirectory.cpp.
References TTHash::append(), TTValue::append(), TTAddress::countSeparator(), TTAddress::getAttribute(), getTTNode(), TTAddress::getType(), kAddressCreated, kAddressRelative, kTTErrGeneric, and notifyObservers().
Create an alias address.
alias | The alias address to remove |
Definition at line 373 of file TTNodeDirectory.cpp.
References TTNode::getAddress(), getTTNode(), kAddressDestroyed, kTTErrGeneric, notifyObservers(), and TTHash::remove().
TTErr TTNodeDirectory::fillAddressItem | ( | TTAddressItemPtr | anAddressItem, |
TTAddress | startAddress = kTTAdrsRoot |
||
) |
fill an address item using the TTNodeDirectory from an address
anAddressItem | an address item |
startAddress | an address where to start from |
Definition at line 177 of file TTNodeDirectory.cpp.
References TTAddress::appendAddress(), TTNode::getAddress(), TTNode::getChildren(), getTTNode(), kTTErrGeneric, kTTErrNone, and kTTErrValueNotFound.
Given an address, return an alias if exists.
anAddress | The address for which to find the TTNode. |
returnedAlias | The . |
Definition at line 100 of file TTNodeDirectory.cpp.
References TTAddress::compare(), TTHash::getKeys(), kAddressEqual, kTTErrNone, and TTHash::lookup().
Given an address, return a pointer to a TTNode.
anAddress | A pointer to the address for which to find the TTNode (it is replaced by the real address if it contains an alias). |
returnedTTNode | The . |
Definition at line 73 of file TTNodeDirectory.cpp.
Referenced by AliasCreate(), AliasRemove(), fillAddressItem(), Lookup(), and TTNodeRemove().
TTErr TTNodeDirectory::IsThere | ( | TTListPtr | whereToSearch, |
TTBoolean(*)(TTNodePtr node, void *args) | testFunction, | ||
void * | argument, | ||
bool * | isThere, | ||
TTNodePtr * | firstTTNode | ||
) |
Is there is one TTNode or more that respect a test below an address.
whereToSearch | A TTNode list from where to start the research |
testFunction | the test function have to take a TTNode as first argument, and a pointer to something as second argument (a structure for example) it have to return a boolean (true means that the node is ok). |
argument | argument for the testFunction. |
isThere | a pointer will be set to true if there is one node that respect the testFunction. |
firstReturnedTTNode | If non-null, the address of the first TTNode object pointer that is found for the given pattern is returned here. The value of the pointer will be set upon return. |
Definition at line 538 of file TTNodeDirectory.cpp.
References TTNode::getChildren(), kTTErrGeneric, and kTTErrNone.
TTErr TTNodeDirectory::LookFor | ( | TTListPtr | whereToSearch, |
TTBoolean(*)(TTNodePtr node, TTPtr args) | testFunction, | ||
void * | argument, | ||
TTList & | returnedTTNodes, | ||
TTNodePtr * | firstReturnedTTNode, | ||
TTUInt8 | depthLimit = 0 , |
||
TTBoolean(*)(TTValue &v1, TTValue &v2) | comparisonFunction = NULL |
||
) |
Find TTNodes by testing each TTNodes below an address.
whereToSearch | A TTNode list from where to start the research |
testFunction | the test function have to take a TTNode as first argument, and a pointer to something as second argument (a structure for example) it have to return a boolean (true means that the node is ok). |
argument | argument for the testFunction |
returnedTTNodes | If non-null, a pointer will be set to the linked-list of TTNodes at the given address pattern. |
firstReturnedTTNode | If non-null, the address of the first TTNode object pointer that is found for the given pattern is returned here. The value of the pointer will be set upon return. |
depthLimit | Precise the depth limit of the exploration (0 means no limit) |
comparisonfunction | To sort the children at each level |
Definition at line 464 of file TTNodeDirectory.cpp.
References TTNode::getChildren(), kTTErrGeneric, and kTTErrNone.
TTErr TTNodeDirectory::Lookup | ( | TTAddress | anAddress, |
TTList & | returnedTTNodes, | ||
TTNodePtr * | firstReturnedTTNode | ||
) |
Find TTNodes by address.
anAddress | The address you wish to find, possibly including wildcards and instance names/numbers. |
returnedTTNodes | If non-null, a pointer will be set to the linked-list of TTNodes at the given address pattern. |
firstReturnedTTNode | If non-null, the address of the first TTNode object pointer that is found for the given pattern is returned here. The value of the pointer will be set upon return. |
Definition at line 400 of file TTNodeDirectory.cpp.
References TTAddress::appendInstance(), TTSymbol::c_str(), TTNode::getChildren(), TTAddress::getInstance(), TTAddress::getName(), TTAddress::getParent(), getTTNode(), TTAddress::getType(), kAddressAbsolute, kTTErrGeneric, and kTTErrNone.
TTErr TTNodeDirectory::notifyObservers | ( | TTAddress | anAddress, |
TTNodePtr | aNode, | ||
TTAddressNotificationFlag | flag | ||
) |
Notify life cycle observers that something appends below this TTNode.
data | an address where something append |
aNode | a TTNodePtr where something append (NULL in case of destruction) |
flag | a flag to notify about creation or destruction (or anything else) |
Definition at line 673 of file TTNodeDirectory.cpp.
References TTValue::append(), TTAddress::compare(), TTHash::getKeys(), TTHash::isEmpty(), kAddressDifferent, kAddressEqual, kAddressLower, kAddressUpper, kTTErrGeneric, kTTErrNone, TTHash::lookup(), TTAddress::normalize(), replaceAlias(), TTObject::send(), and TTValue::size().
Referenced by AliasCreate(), AliasRemove(), TTNode::setNameInstance(), TTNodeCreate(), and TTNodeRemove().
TTErr TTNodeDirectory::removeObserverForNotifications | ( | TTAddress | anAddress, |
TTObject & | anObserver | ||
) |
Remove a TTCallback as a life cycle observer of all nodes below this one.
anAddress | an address |
observer | a TTCallback object to remove |
Definition at line 630 of file TTNodeDirectory.cpp.
References TTObject::instance(), kTTErrValueNotFound, TTHash::lookup(), TTAddress::normalize(), and TTHash::remove().
Given an address with alias, return an address with no alias if exists.
anAddress | The address with an alias inside to replace. |
Definition at line 126 of file TTNodeDirectory.cpp.
References TTAddress::appendAddress(), TTAddress::compare(), TTHash::getKeys(), kAddressEqual, kAddressLower, kTTErrGeneric, kTTErrNone, TTHash::lookup(), TTValue::size(), and TTAddress::splitAt().
Referenced by notifyObservers().
Set the name of the TTNodeDirectory.
newName | The name to set |
Definition at line 52 of file TTNodeDirectory.cpp.
References kTTErrNone.
TTErr TTNodeDirectory::TTNodeCreate | ( | TTAddress & | anAddress, |
TTObject & | newObject, | ||
void * | aContext, | ||
TTNodePtr * | returnedTTNode, | ||
TTBoolean * | nodeCreated | ||
) |
Create a new TTNode, at the given location in the tree.
anAddress | The address for which you wish to create a TTNode. The address may (optionally) include an instance name or number in the address of the terminal TTNode. If you specify an instance name/number that already exists, then returnedTTNode will be a pointer to the already existing TTNode upon return and no new TTNode will be created. If you do not specify an instance name/number, then one will be generated for you automatically. |
newObject | The object, if applicable, that is represented by this TTNode. |
aContext | The context in which the object is. |
returnedTTNode | A pointer to the TTNode at the given address |
nodeCreated | A boolean : true if a TTNode have been created, else false |
Definition at line 221 of file TTNodeDirectory.cpp.
References TTHash::append(), TTNode::generateInstance(), TTNode::getAddress(), TTNode::getContext(), TTAddress::getInstance(), TTAddress::getName(), TTNode::getName(), TTAddress::getParent(), TTNode::getParent(), kAddressCreated, kTTErrNone, kTTErrValueNotFound, TTHash::lookup(), TTAddress::normalize(), notifyObservers(), TTNode::setChild(), TTNode::setContext(), and TTNode::setParent().
Referenced by init(), and TTNode::setParent().
Remove a TTNodefrom the directory.
anAddress | The address for which you wish to remove the TTNode. The address may (optionally) include an instance name or number in the address of the terminal TTNode. |
Definition at line 292 of file TTNodeDirectory.cpp.
References TTNode::getAddress(), TTNode::getChildren(), TTNode::getObject(), TTNode::getParent(), getTTNode(), kAddressDestroyed, kTTErrGeneric, TTAddress::normalize(), notifyObservers(), TTHash::remove(), and TTObject::valid().
Referenced by TTNode::~TTNode().