Jamoma API  0.6.0.a19
TTNode Class Reference

We build a directory of TTNodes, and you can request a pointer for any TTNode, or add an observer to any TTNode, etc. More...

#include <TTNode.h>

Public Member Functions

 TTNode (TTSymbol &aName, TTSymbol &anInstance, TTObject &anObject, TTPtr aContext, TTNodeDirectoryPtr aDirectory)
 Constructor. More...
 
virtual ~TTNode ()
 Destructor.
 
TTErr setNameInstance (TTAddress &aNameInstance, TTSymbol &newInstance, TTBoolean *newInstanceCreated)
 Set the name and the instance of the node. More...
 
TTErr setParent (TTAddress parentAddress, TTBoolean *newParentCreated)
 Set the parent of the node. More...
 
TTErr setChild (TTNodePtr child)
 Add a node as a child of the node. More...
 
TTErr setObject (TTObject anObject=TTObject())
 Set the object of the node. More...
 
TTErr setContext (TTPtr aContext)
 Set the context of the node. More...
 
TTSymbolgetName ()
 Get the name of the node. More...
 
TTSymbolgetInstance ()
 Get the instance of the node. More...
 
TTNodePtr getParent ()
 Get a pointer to the parent node of the node. More...
 
TTErr getChildren (TTSymbol &name, TTSymbol &instance, TTList &returnedChildren)
 Get a linklist of children of the node : select them by name and instance (use wilcards to select them all) More...
 
TTErr getChildrenName (TTList &returnedChildrenName)
 Get a linklist of children name. More...
 
TTErr getChildrenInstance (TTSymbol &aName, TTList &returnedChildrenInstance)
 Get a linklist of children instance for a given name. More...
 
TTObjectgetObject ()
 Get the object binded by this node. More...
 
TTPtr getContext ()
 Get a pointer to the context of this node. More...
 
TTErr getAddress (TTAddress &returnedAddress, TTAddress from=kTTAdrsEmpty)
 Get the address of the node. More...
 
TTErr generateInstance (TTSymbol &childName, TTSymbol &newInstance)
 Generate a new instance of a given child. More...
 

Detailed Description

We build a directory 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 directory. If a TTNode is specified, such as /degrade~/audio/mute, and we assume degrade~ has been added to the directory but 'audio' hasn't, then 'audio' is added followed by adding 'mute', so that the directory is properly completed.

When a TTNode is requested, the directory 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 59 of file TTNode.h.

Constructor & Destructor Documentation

TTNode::TTNode ( TTSymbol aName,
TTSymbol anInstance,
TTObject anObject,
TTPtr  aContext,
TTNodeDirectoryPtr  aDirectory 
)

Constructor.

Parameters
aNamethe name of the node
anInstancean instance symbol
anObjectan object referenced by the node
aContextany pointer to precise the object place in its environnement
aDirectorya pointer to a node directory

Definition at line 13 of file TTNode.cpp.

Member Function Documentation

TTErr TTNode::generateInstance ( TTSymbol childName,
TTSymbol newInstance 
)

Generate a new instance of a given child.

Parameters
childNamethe name of a child.
newInstancea new instance created (or "" if not) .
Returns
TTErr a kTTErrGeneric if the child doesn't exist.

Definition at line 578 of file TTNode.cpp.

References kTTErrGeneric, kTTErrNone, kTTErrValueNotFound, TTHash::lookup(), and TT.

Referenced by setNameInstance(), and TTNodeDirectory::TTNodeCreate().

+ Here is the call graph for this function:

TTErr TTNode::getAddress ( TTAddress returnedAddress,
TTAddress  from = kTTAdrsEmpty 
)

Get the address of the node.

It is computed dynamicaly by asking to all the ancestor of the node

Parameters
returnedAddressa TTAddress with the address is returned in this parameter.
froman address from where to start the returned address in order to have a relative address
Returns
TTErr an error code

Definition at line 478 of file TTNode.cpp.

References TTSymbol::c_str(), TTAddress::countSeparator(), kTTErrGeneric, kTTErrNone, TTAddress::normalize(), TTValue::resize(), and TTAddress::splitAt().

Referenced by TTNodeDirectory::AliasRemove(), TTNodeDirectory::fillAddressItem(), in_subscribe(), model_subscribe_view(), out_subscribe(), setNameInstance(), TTExplorerDirectoryCallback(), TTNodeDirectory::TTNodeCreate(), TTNodeDirectory::TTNodeRemove(), and ~TTNode().

+ Here is the call graph for this function:

TTErr TTNode::getChildren ( TTSymbol name,
TTSymbol instance,
TTList &  returnedChildren 
)

Get a linklist of children of the node : select them by name and instance (use wilcards to select them all)

Returns
TTErr an error code

Definition at line 301 of file TTNode.cpp.

References TTHash::getKeys(), TTHash::getSize(), kTTErrGeneric, kTTErrNone, and TTHash::lookup().

Referenced by TTNodeDirectory::fillAddressItem(), TTNodeDirectory::IsThere(), TTNodeDirectory::LookFor(), TTNodeDirectory::Lookup(), and TTNodeDirectory::TTNodeRemove().

+ Here is the call graph for this function:

TTErr TTNode::getChildrenInstance ( TTSymbol aName,
TTList &  returnedChildrenInstance 
)

Get a linklist of children instance for a given name.

Returns
TTErr an error code

Definition at line 424 of file TTNode.cpp.

References TTValue::append(), TTHash::clear(), TTHash::getKeys(), TTHash::getSize(), kTTErrGeneric, kTTErrNone, and TTHash::lookup().

+ Here is the call graph for this function:

TTErr TTNode::getChildrenName ( TTList &  returnedChildrenName)

Get a linklist of children name.

Returns
TTErr an error code

Definition at line 397 of file TTNode.cpp.

References TTValue::append(), TTHash::getKeys(), TTHash::getSize(), kTTErrGeneric, and kTTErrNone.

+ Here is the call graph for this function:

TTPtr TTNode::getContext ( )

Get a pointer to the context of this node.

Returns
TTPtr the context pointer

Definition at line 473 of file TTNode.cpp.

Referenced by model_subscribe(), TTContainerTestObjectAndContext(), and TTNodeDirectory::TTNodeCreate().

TTSymbol & TTNode::getInstance ( )

Get the instance of the node.

Returns
TTSymbol the instance of the node

Definition at line 291 of file TTNode.cpp.

TTSymbol & TTNode::getName ( )

Get the name of the node.

Returns
TTSymbol the name of the node

Definition at line 286 of file TTNode.cpp.

Referenced by TTContainerTestObjectAndContext(), and TTNodeDirectory::TTNodeCreate().

TTNodePtr TTNode::getParent ( )

Get a pointer to the parent node of the node.

Returns
#TTNodePtr the parent node

Definition at line 296 of file TTNode.cpp.

Referenced by in_subscribe(), model_subscribe(), out_subscribe(), TTContainerTestObjectAndContext(), TTExplorerDirectoryCallback(), TTNodeDirectory::TTNodeCreate(), and TTNodeDirectory::TTNodeRemove().

TTErr TTNode::setChild ( TTNodePtr  child)

Add a node as a child of the node.

Parameters
childa TTNodePtr to add as children of the TTNode.
Returns
TTErr a kTTErrGeneric if the instance of the given child already exist.

Definition at line 227 of file TTNode.cpp.

References TTHash::append(), kTTErrGeneric, kTTErrNone, kTTErrValueNotFound, and TTHash::lookup().

Referenced by setNameInstance(), and TTNodeDirectory::TTNodeCreate().

+ Here is the call graph for this function:

TTErr TTNode::setContext ( TTPtr  aContext)

Set the context of the node.

Parameters
aContextany pointer usefull to precise a context
Returns
TTErr always returns kTTErrNone

Definition at line 277 of file TTNode.cpp.

References kTTErrNone.

Referenced by TTNodeDirectory::TTNodeCreate().

TTErr TTNode::setNameInstance ( TTAddress aNameInstance,
TTSymbol newInstance,
TTBoolean newInstanceCreated 
)

Set the name and the instance of the node.

It maintains the directory and the directory

Parameters
aNameInstanceTTAddress name.instance to set
newInstancethe returned TTSymbol instance if a new have been created
newInstanceCreatedtrue if a new instance have been created
Returns
TTErr an error code

Definition at line 101 of file TTNode.cpp.

References TTHash::append(), TTSymbol::c_str(), generateInstance(), getAddress(), TTNodeDirectory::getDirectory(), TTAddress::getInstance(), TTHash::getKeys(), TTAddress::getName(), TTHash::getSize(), kAddressCreated, kAddressDestroyed, kTTErrGeneric, kTTErrNone, kTTErrValueNotFound, TTHash::lookup(), TTNodeDirectory::notifyObservers(), TTHash::remove(), setChild(), and TTValue::size().

+ Here is the call graph for this function:

TTErr TTNode::setObject ( TTObject  anObject = TTObject())

Set the object of the node.

Parameters
anObjectthe object to reference
Returns
TTErr always returns kTTErrNone

Definition at line 271 of file TTNode.cpp.

References kTTErrNone.

TTErr TTNode::setParent ( TTAddress  parentAddress,
TTBoolean newParentCreated 
)

Set the parent of the node.

This method ensure that the path to the node exist

Parameters
parentAddressThe address to check
newParentCreatedThis parameter will be set to true upon return if a new TTNode was created, or false if one was not created - e.g. because a TTNode already existed with this address and instance name.
Returns
TTErr an error code

Definition at line 202 of file TTNode.cpp.

References TTNodeDirectory::getDirectory(), kTTErrGeneric, kTTErrNone, kTTErrValueNotFound, TTHash::lookup(), and TTNodeDirectory::TTNodeCreate().

Referenced by TTNodeDirectory::TTNodeCreate().

+ Here is the call graph for this function:


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