Jamoma API  0.6.0.a19
TTNodeDirectory Class Reference

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...
 

Detailed Description

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.

Member Function Documentation

TTErr TTNodeDirectory::addObserverForNotifications ( TTAddress  anAddress,
TTObject anObserver,
TTInt8  maxDepthDifference = -1 
)

Add a TTCallback as a life cycle observer of all nodes below this one.

Parameters
anAddressan address to observe
observera TTCallback object to add
maxDepthDifferenceprecise the max depth difference to filter nodes which are below this limit
Returns
an error code

Definition at line 590 of file TTNodeDirectory.cpp.

References TTHash::append(), TTValue::append(), kTTErrNone, kTTErrValueNotFound, TTHash::lookup(), and TTAddress::normalize().

+ Here is the call graph for this function:

TTErr TTNodeDirectory::AliasCreate ( TTAddress  alias,
TTAddress  anAddress 
)

Create an alias address.

Parameters
aliasThe alias address (absolute)
anAddressThe address for which you wish to create an alias.
Returns
An error code.

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().

+ Here is the call graph for this function:

TTErr TTNodeDirectory::AliasRemove ( TTAddress  alias)

Create an alias address.

Parameters
aliasThe alias address to remove
Returns
An error code.

Definition at line 373 of file TTNodeDirectory.cpp.

References TTNode::getAddress(), getTTNode(), kAddressDestroyed, kTTErrGeneric, notifyObservers(), and TTHash::remove().

+ Here is the call graph for this function:

TTErr TTNodeDirectory::fillAddressItem ( TTAddressItemPtr  anAddressItem,
TTAddress  startAddress = kTTAdrsRoot 
)

fill an address item using the TTNodeDirectory from an address

Parameters
anAddressIteman address item
startAddressan address where to start from
Returns
An error code if the address item cannont be filled

Definition at line 177 of file TTNodeDirectory.cpp.

References TTAddress::appendAddress(), TTNode::getAddress(), TTNode::getChildren(), getTTNode(), kTTErrGeneric, kTTErrNone, and kTTErrValueNotFound.

+ Here is the call graph for this function:

TTErr TTNodeDirectory::getAlias ( TTAddress  anAddress,
TTAddress returnedAlias 
)

Given an address, return an alias if exists.

Parameters
anAddressThe address for which to find the TTNode.
returnedAliasThe .
Returns
An error code if there is no alias.

Definition at line 100 of file TTNodeDirectory.cpp.

References TTAddress::compare(), TTHash::getKeys(), kAddressEqual, kTTErrNone, and TTHash::lookup().

+ Here is the call graph for this function:

TTErr TTNodeDirectory::getTTNode ( const char *  anAddress,
TTNodePtr returnedTTNode 
)

Given an address, return a pointer to a TTNode.

Parameters
anAddressA pointer to the address for which to find the TTNode (it is replaced by the real address if it contains an alias).
returnedTTNodeThe .
Returns
An error code.

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.

Parameters
whereToSearchA TTNode list from where to start the research
testFunctionthe 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).
argumentargument for the testFunction.
isTherea pointer will be set to true if there is one node that respect the testFunction.
firstReturnedTTNodeIf 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.
Returns
An error code.

Definition at line 538 of file TTNodeDirectory.cpp.

References TTNode::getChildren(), kTTErrGeneric, and kTTErrNone.

+ Here is the call graph for this function:

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.

Parameters
whereToSearchA TTNode list from where to start the research
testFunctionthe 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).
argumentargument for the testFunction
returnedTTNodesIf non-null, a pointer will be set to the linked-list of TTNodes at the given address pattern.
firstReturnedTTNodeIf 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.
depthLimitPrecise the depth limit of the exploration (0 means no limit)
comparisonfunctionTo sort the children at each level
Returns
An error code.

Definition at line 464 of file TTNodeDirectory.cpp.

References TTNode::getChildren(), kTTErrGeneric, and kTTErrNone.

+ Here is the call graph for this function:

TTErr TTNodeDirectory::Lookup ( TTAddress  anAddress,
TTList &  returnedTTNodes,
TTNodePtr firstReturnedTTNode 
)

Find TTNodes by address.

Parameters
anAddressThe address you wish to find, possibly including wildcards and instance names/numbers.
returnedTTNodesIf non-null, a pointer will be set to the linked-list of TTNodes at the given address pattern.
firstReturnedTTNodeIf 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.
Returns
An error code.

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.

+ Here is the call graph for this function:

TTErr TTNodeDirectory::notifyObservers ( TTAddress  anAddress,
TTNodePtr  aNode,
TTAddressNotificationFlag  flag 
)

Notify life cycle observers that something appends below this TTNode.

Parameters
dataan address where something append
aNodea TTNodePtr where something append (NULL in case of destruction)
flaga flag to notify about creation or destruction (or anything else)
Returns
a kTTErrGeneric if there isn't observer

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().

+ Here is the call graph for this function:

TTErr TTNodeDirectory::removeObserverForNotifications ( TTAddress  anAddress,
TTObject anObserver 
)

Remove a TTCallback as a life cycle observer of all nodes below this one.

Parameters
anAddressan address
observera TTCallback object to remove
Returns
a kTTErrGeneric if there isn't observer

Definition at line 630 of file TTNodeDirectory.cpp.

References TTObject::instance(), kTTErrValueNotFound, TTHash::lookup(), TTAddress::normalize(), and TTHash::remove().

+ Here is the call graph for this function:

TTErr TTNodeDirectory::replaceAlias ( TTAddress anAddress)

Given an address with alias, return an address with no alias if exists.

Parameters
anAddressThe address with an alias inside to replace.
Returns
An error code if there is no alias.

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().

+ Here is the call graph for this function:

TTErr TTNodeDirectory::setName ( TTSymbol  aname)

Set the name of the TTNodeDirectory.

Parameters
newNameThe 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.

Parameters
anAddressThe 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.
newObjectThe object, if applicable, that is represented by this TTNode.
aContextThe context in which the object is.
returnedTTNodeA pointer to the TTNode at the given address
nodeCreatedA boolean : true if a TTNode have been created, else false
Returns
An error code.

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().

+ Here is the call graph for this function:

TTErr TTNodeDirectory::TTNodeRemove ( TTAddress anAddress)

Remove a TTNodefrom the directory.

Parameters
anAddressThe 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.
Returns
An error code.

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().

+ Here is the call graph for this function:


The documentation for this class was generated from the following files: