18 #include <libxml/encoding.h>
19 #include <libxml/xmlwriter.h>
20 #include <libxml/xmlreader.h>
22 #define thisTTClass TTApplication
23 #define thisTTClassName "Application"
24 #define thisTTClassTags "modularLibrary, application"
26 TT_MODULAR_CONSTRUCTOR,
30 mVersion(kTTSymEmpty),
35 mTempAddress(kTTAdrsRoot)
49 this->findAttribute(
TTSymbol(
"activityIn"), &anAttribute);
53 this->findAttribute(
TTSymbol(
"activityOut"), &anAttribute);
57 this->findAttribute(
TTSymbol(
"cachedAttributes"), &anAttribute);
133 TT_ASSERT(
"NodeDirectory created successfully", (mDirectory != NULL));
138 #pragma mark Destructor
141 TTApplication::~TTApplication()
150 #pragma mark Attribute accesors
175 protocolName = protocols[i];
176 accessProtocol(protocolName)->setAttributeValue(kTTSym_activity, mActivity);
189 TTErr TTApplication::setActivityIn(
const TTValue& value)
208 TTErr TTApplication::setActivityOut(
const TTValue& value)
220 TTErr TTApplication::getCachedAttributes(
TTValue& value)
223 if (mType != kTTSym_mirror)
226 mCachedAttributes.
getKeys(value);
231 TTErr TTApplication::setCachedAttributes(
const TTValue& value)
234 if (mType != kTTSym_mirror)
242 TTHash lastCachedAttributes;
247 for (i = 0; i < v.
size(); i++) {
250 lastCachedAttributes.
append(name, none);
254 mCachedAttributes.
clear();
255 for (i = 0; i < value.
size(); i++) {
258 mCachedAttributes.
append(name, none);
261 if (lastCachedAttributes.
lookup(name, none))
262 cacheAttributeNode(mDirectory->
getRoot(), name, YES);
266 lastCachedAttributes.
getKeys(v);
267 for (i = 0; i < v.
size(); i++) {
272 if (mCachedAttributes.
lookup(name, none))
273 cacheAttributeNode(mDirectory->
getRoot(), name, NO);
289 if (anObject.
valid()) {
292 anObject.
send(
"AttributeCache", attributeName);
294 anObject.
send(
"AttributeUncache", attributeName);
298 aNode->
getChildren(S_WILDCARD, S_WILDCARD, nodeList);
300 for (nodeList.begin(); nodeList.end(); nodeList.next())
303 cacheAttributeNode(aChild, attributeName, cacheOrUncache);
309 TTErr TTApplication::Init()
311 return initNode(mDirectory->
getRoot());
323 anObject.
send(kTTSym_Init);
326 aNode->
getChildren(S_WILDCARD, S_WILDCARD, nodeList);
329 nodeList.sort(&compareNodePriorityThenNameThenInstance);
331 for (nodeList.begin(); nodeList.end(); nodeList.next())
340 TTErr TTApplication::DirectoryClear()
352 TTErr TTApplication::DirectoryBuild()
367 protocolName = protocolNames[0];
371 return buildNode(aProtocol, kTTAdrsRoot);
386 err = aProtocol->
SendDiscoverRequest(mName, anAddress, returnedType, returnedChildren, returnedAttributes);
390 if (anAddress != kTTAdrsRoot) {
392 if (mType == kTTSym_mirror) {
395 TTValue attributesToCache, v, args, none;
397 anObject = appendMirrorObject(aProtocol, anAddress, returnedType, returnedAttributes);
399 if (anObject.
valid()) {
402 mCachedAttributes.
getKeys(attributesToCache);
403 for (
TTUInt32 i = 0; i < attributesToCache.
size(); i++) {
405 cachedAttribute = attributesToCache[i];
411 args = cachedAttribute;
413 anObject.
send(
"AttributeCache", args);
419 else if (mType == kTTSym_proxy) {
422 if (returnedType == kTTSym_Data) {
429 service = returnedValue[0];
431 anObject = appendProxyData(aProtocol, anAddress, service);
440 for (
TTUInt32 i = 0; i < returnedChildren.
size(); i++) {
442 childAddress = returnedChildren[i];
446 if (buildNode(aProtocol, nextAddress))
456 if (inputValue.
size() == 1)
487 appToNotify = inputValue[1];
488 whereToListen = inputValue[2];
490 editKey = appToNotify.
c_str();
492 editKey += whereToListen.
c_str();
496 if (mDirectoryListenersCache.
lookup(key, cacheElement)) {
499 returnValueCallback =
TTObject(
"callback");
501 returnValueCallback.
set(kTTSym_baton, inputValue);
509 cacheElement.
append(returnValueCallback);
510 return mDirectoryListenersCache.
append(key, cacheElement);
519 TTErr TTApplication::RemoveDirectoryListener(
const TTValue& inputValue,
TTValue& outputValue)
527 appToNotify = inputValue[0];
528 whereToListen = inputValue[1];
530 editKey = appToNotify.
c_str();
532 editKey += whereToListen.
c_str();
536 if (!mDirectoryListenersCache.
lookup(key, cacheElement)) {
538 returnValueCallback = cacheElement[0];
541 return mDirectoryListenersCache.
remove(key);
559 appToNotify = inputValue[1];
560 whereToListen = inputValue[2];
562 editKey = appToNotify.
c_str();
564 editKey += whereToListen.
c_str();
568 if (mAttributeListenersCache.
lookup(key, cacheElement)) {
570 err = mDirectory->
Lookup(whereToListen, aNodeList, &nodeToListen);
574 for (aNodeList.begin(); aNodeList.end(); aNodeList.next())
580 if (anObject.valid()) {
584 err = anObject.instance()->findAttribute(whereToListen.
getAttribute(), &anAttribute);
590 returnValueCallback.
set(kTTSym_baton, inputValue);
599 cacheElement.
append(returnValueCallback);
604 return mAttributeListenersCache.
append(key, cacheElement);
614 TTErr TTApplication::RemoveAttributeListener(
const TTValue& inputValue,
TTValue& outputValue)
627 appToNotify = inputValue[0];
628 whereToListen = inputValue[1];
630 editKey = appToNotify.
c_str();
632 editKey += whereToListen.
c_str();
636 if (!mAttributeListenersCache.
lookup(key, cacheElement)) {
638 err = mDirectory->
Lookup(whereToListen, aNodeList, &nodeToListen);
643 for (aNodeList.begin(); aNodeList.end(); aNodeList.next())
649 if (anObject.valid()) {
653 err = anObject.instance()->findAttribute(whereToListen.
getAttribute(), &anAttribute);
657 TTObject returnValueCallback = cacheElement[i];
666 return mAttributeListenersCache.
remove(key);
684 whereComesFrom = inputValue[0];
693 err = mDirectory->
Lookup(whereComesFrom, aNodeList, &aNode);
696 if (type !=
TTSymbol(
"delete") && err) {
704 if (mType == kTTSym_mirror)
706 appendMirrorObject(aProtocol, whereComesFrom, type, none);
708 if (mType == kTTSym_proxy) {
711 TTObject aData = appendProxyData(aProtocol, whereComesFrom, kTTSym_parameter);
716 aData.
set(
"value", *newValue);
724 else if (!err && type ==
TTSymbol(
"delete"))
739 UpdateDirectory(inputValue, outputValue);
741 whereComesFrom = inputValue[0];
744 err = mDirectory->
getTTNode(whereComesFrom, &nodeToUpdate);
749 if (anObject.
valid()) {
751 if (anObject.
name() == kTTSym_Mirror)
764 if (inputValue.
size() >= 2) {
772 TTPtr context = NULL;
773 if (inputValue.
size() == 3)
775 context = inputValue[2];
781 if (address == kTTAdrsRoot)
785 TTErr err = mDirectory->
TTNodeCreate(address,
object, context, &node, &newInstanceCreated);
790 if (newInstanceCreated)
793 outputValue = address;
807 if (inputValue.
size() == 1) {
816 if (!mDirectory->
getTTNode(address, &node)) {
822 if (address == kTTAdrsRoot) {
837 if (inputValue.
size() == 2) {
842 TTAddress newNameInstance = inputValue[1];
852 aNodeList.append(mDirectory->
getRoot());
854 TTErr err = mDirectory->
IsThere(&aNodeList, &testNodeObject, anObject.
instance(), &isThere, &aNode);
856 if (!err && isThere) {
859 TTSymbol newInstance, effectiveNameInstance;
862 aNode->
setNameInstance(newNameInstance, newInstance, &newInstanceCreated);
880 if (inputValue.
size() == 1) {
889 TTErr err = mDirectory->
Lookup(address, aNodeList, &aNode);
893 for (aNodeList.begin(); aNodeList.end(); aNodeList.next())
900 if (anObject.valid()) {
903 outputValue.
append(anObject);
919 std::cout <<
"ObjectSend" << std::endl;
921 if (inputValue.
size() >= 1) {
930 TTErr err = mDirectory->
Lookup(address, aNodeList, &aNode);
934 std::cout <<
"ok" << std::endl;
939 valueToSend.
copyFrom(inputValue, 1);
941 for (aNodeList.begin(); aNodeList.end(); aNodeList.next())
948 if (anObject.valid()) {
951 if (anObject.name() == kTTSym_Data) {
954 err = anObject.
send(kTTSym_Command, valueToSend);
956 err = anObject.set(address.
getAttribute(), valueToSend);
960 err = anObject.set(address.
getAttribute(), valueToSend);
964 err = anObject.send(address.
getAttribute(), valueToSend);
979 TTValue valueToSend, protocolNames;
982 valueToSend.
copyFrom(inputValue, 1);
986 protocolName = protocolNames[0];
1003 value = kTTSymEmpty;
1013 value = kTTSymEmpty;
1028 if (inputValue.
size() == 1) {
1032 ttName = inputValue[0];
1033 return this->mTTToApp.
lookup(ttName, outputValue);
1041 ttName = inputValue[i];
1042 if (!this->mTTToApp.
lookup(ttName, c)) {
1044 outputValue[i] = appName;
1059 if (inputValue.
size() == 1) {
1063 appName = inputValue[0];
1064 return this->mAppToTT.
lookup(appName, outputValue);
1072 appName = inputValue[i];
1073 if (!this->mAppToTT.
lookup(appName, c)) {
1075 outputValue[i] = ttName;
1090 xmlTextWriterStartElement((xmlTextWriterPtr)aXmlHandler->mWriter, BAD_CAST
"application");
1093 xmlTextWriterWriteAttribute((xmlTextWriterPtr)aXmlHandler->mWriter, BAD_CAST
"name", BAD_CAST mName.
c_str());
1094 xmlTextWriterWriteAttribute((xmlTextWriterPtr)aXmlHandler->mWriter, BAD_CAST
"author", BAD_CAST mAuthor.
c_str());
1095 xmlTextWriterWriteAttribute((xmlTextWriterPtr)aXmlHandler->mWriter, BAD_CAST
"version", BAD_CAST mVersion.
c_str());
1096 xmlTextWriterWriteAttribute((xmlTextWriterPtr)aXmlHandler->mWriter, BAD_CAST
"type", BAD_CAST mType.
c_str());
1099 if (mType == kTTSym_mirror) {
1105 xmlTextWriterWriteAttribute((xmlTextWriterPtr)aXmlHandler->mWriter, BAD_CAST
"cachedAttributes", BAD_CAST s.
c_str());
1110 writeNodeAsXml(aXmlHandler, mDirectory->
getRoot());
1113 xmlTextWriterEndElement((xmlTextWriterPtr)aXmlHandler->mWriter);
1121 TTSymbol objectName, attributeName;
1123 TTValue attributeNameList, v, c, none;
1131 if (anObject.
valid()) {
1133 objectName = anObject.
name();
1135 if (objectName == kTTSym_Mirror)
1141 if (objectName != kTTSym_Application) {
1144 if (mType != kTTSym_mirror) {
1146 if (anObject.
valid()) {
1148 if (!anObject.
get(kTTSym_description, v)) {
1152 xmlTextWriterWriteFormatComment((xmlTextWriterPtr)aXmlHandler->mWriter,
"%s", BAD_CAST aString.data());
1158 xmlTextWriterStartElement((xmlTextWriterPtr)aXmlHandler->mWriter, BAD_CAST
"node");
1162 xmlTextWriterWriteAttribute((xmlTextWriterPtr)aXmlHandler->mWriter, BAD_CAST
"address", BAD_CAST nameInstance.
c_str());
1165 if (objectName != kTTSymEmpty)
1166 xmlTextWriterWriteAttribute((xmlTextWriterPtr)aXmlHandler->mWriter, BAD_CAST
"object", BAD_CAST objectName.
c_str());
1169 if (objectName != kTTSym_Data &&
1170 objectName != kTTSym_Mirror &&
1171 objectName != kTTSym_Container &&
1172 objectName != kTTSym_Input &&
1173 objectName != kTTSym_InputAudio &&
1174 objectName != kTTSym_Output &&
1175 objectName != kTTSym_OutputAudio)
1179 else if (anObject.
valid()) {
1185 attributeName = attributeNameList[i];
1188 if (attributeName != kTTSym_description &&
1189 attributeName != kTTSym_value &&
1190 attributeName != kTTSym_address &&
1191 attributeName != kTTSym_bypass &&
1192 attributeName != kTTSym_activityIn &&
1193 attributeName != kTTSym_activityOut &&
1194 attributeName != kTTSym_rampStatus &&
1195 attributeName != kTTSym_baton &&
1196 attributeName != kTTSym_object &&
1197 attributeName != kTTSym_notification &&
1198 attributeName != kTTSym_function)
1202 if (mType == kTTSym_mirror)
1203 if (mCachedAttributes.
lookup(attributeName, none))
1206 anObject.
get(attributeName, v);
1214 if (aString.empty())
1217 xmlTextWriterWriteAttribute((xmlTextWriterPtr)aXmlHandler->mWriter, BAD_CAST attributeName.
c_str(), BAD_CAST aString.data());
1226 aNode->
getChildren(S_WILDCARD, S_WILDCARD, nodeList);
1228 for (nodeList.begin(); nodeList.end(); nodeList.next())
1231 writeNodeAsXml(aXmlHandler, aChild);
1236 if (objectName != kTTSym_Application)
1237 xmlTextWriterEndElement((xmlTextWriterPtr)aXmlHandler->mWriter);
1248 TTValue appValue, ttValue, v, nameValue, parameterValue;
1253 if (aXmlHandler->
mXmlNodeName == kTTSym_xmlHandlerReadingStarts)
1257 if (aXmlHandler->
mXmlNodeName == kTTSym_xmlHandlerReadingEnds)
1261 if (aXmlHandler->
mXmlNodeName == kTTSym_xmlHandlerReadingComment)
1277 if (xmlTextReaderMoveToAttribute((xmlTextReaderPtr)aXmlHandler->mReader, BAD_CAST
"App") == 1) {
1278 aXmlHandler->
fromXmlChar(xmlTextReaderValue((xmlTextReaderPtr)aXmlHandler->mReader), appValue);
1285 if (xmlTextReaderMoveToAttribute((xmlTextReaderPtr)aXmlHandler->mReader, BAD_CAST
"TT") == 1) {
1286 aXmlHandler->
fromXmlChar(xmlTextReaderValue((xmlTextReaderPtr)aXmlHandler->mReader), ttValue);
1304 mTempAddress = kTTAdrsRoot;
1307 if (xmlTextReaderMoveToAttribute((xmlTextReaderPtr)aXmlHandler->mReader, (
const xmlChar*)(
"type")) == 1) {
1309 aXmlHandler->
fromXmlChar(xmlTextReaderValue((xmlTextReaderPtr)aXmlHandler->mReader), v);
1311 if (v.
size() == 1) {
1321 if (xmlTextReaderMoveToAttribute((xmlTextReaderPtr)aXmlHandler->mReader, (
const xmlChar*)(
"author")) == 1) {
1323 aXmlHandler->
fromXmlChar(xmlTextReaderValue((xmlTextReaderPtr)aXmlHandler->mReader), v, YES);
1325 if (v.
size() == 1) {
1335 if (xmlTextReaderMoveToAttribute((xmlTextReaderPtr)aXmlHandler->mReader, (
const xmlChar*)(
"version")) == 1) {
1337 aXmlHandler->
fromXmlChar(xmlTextReaderValue((xmlTextReaderPtr)aXmlHandler->mReader), v);
1339 if (v.
size() == 1) {
1349 if (xmlTextReaderMoveToAttribute((xmlTextReaderPtr)aXmlHandler->mReader, (
const xmlChar*)(
"cachedAttributes")) == 1) {
1351 aXmlHandler->
fromXmlChar(xmlTextReaderValue((xmlTextReaderPtr)aXmlHandler->mReader), v);
1352 setCachedAttributes(v);
1360 readNodeFromXml(aXmlHandler);
1367 TTSymbol objectName, protocolName, attributeName, attributeToFilterName;
1373 TTValue v, protocolNames, none;
1374 TTHash attributesToFilter;
1380 if (xmlTextReaderMoveToAttribute((xmlTextReaderPtr)aXmlHandler->mReader, (
const xmlChar*)(
"address")) == 1) {
1382 aXmlHandler->
fromXmlChar(xmlTextReaderValue((xmlTextReaderPtr)aXmlHandler->mReader), v, YES, YES);
1384 if (v.
size() == 1) {
1390 if (address ==
TTSymbol(
"instance"))
1391 useInstanceAsName = YES;
1405 if (xmlTextReaderMoveToAttribute((xmlTextReaderPtr)aXmlHandler->mReader, (
const xmlChar*)(
"instance")) == 1) {
1407 aXmlHandler->
fromXmlChar(xmlTextReaderValue((xmlTextReaderPtr)aXmlHandler->mReader), v);
1409 if (v.
size() == 1) {
1416 if (!useInstanceAsName)
1424 mFoldAddress = mTempAddress;
1425 mFolderSize = instance;
1426 TTLogMessage(
"TTApplication::readNodeFromXml : %s is a fold address to duplicate %d times\n", mFoldAddress.
c_str(), mFolderSize);
1436 if (mFoldAddress != kTTAdrsEmpty && mTempAddress == mFoldAddress)
1438 TTLogMessage(
"TTApplication::readNodeFromXml : %s fold address ends\n", mTempAddress.
c_str());
1439 mFoldAddress = kTTAdrsEmpty;
1446 TTInt8 duplicateDepth = 0;
1447 if (mFoldAddress != kTTAdrsEmpty && mFoldAddress != mTempAddress)
1453 duplicate = mFolderSize;
1458 for (
TTUInt32 d = 1; d <= duplicate; d++)
1462 if (mFoldAddress != kTTAdrsEmpty)
1471 for (
TTInt32 i = 0; i < instance; i++)
1473 if (useInstanceAsName)
1482 address = mTempAddress;
1485 if (mFoldAddress != kTTAdrsEmpty && duplicateDepth > 0)
1490 if (useInstanceAsName)
1492 address.
splitAt(splitAt, foldPart, tempPart);
1497 objectName = kTTSymEmpty;
1498 if (xmlTextReaderMoveToAttribute((xmlTextReaderPtr)aXmlHandler->mReader, (
const xmlChar*)(
"object")) == 1) {
1500 aXmlHandler->
fromXmlChar(xmlTextReaderValue((xmlTextReaderPtr)aXmlHandler->mReader), v);
1502 if (v.
size() == 1) {
1511 protocolName = protocolNames[0];
1517 if (mType == kTTSym_mirror) {
1520 anObject = appendMirrorObject(aProtocol, address, objectName, none);
1524 else if (mType == kTTSym_proxy) {
1529 if (objectName == kTTSym_Data) {
1532 if (xmlTextReaderMoveToAttribute((xmlTextReaderPtr)aXmlHandler->mReader, (
const xmlChar*)(
"service")) == 1) {
1534 aXmlHandler->
fromXmlChar(xmlTextReaderValue((xmlTextReaderPtr)aXmlHandler->mReader), v);
1536 if (v.
size() == 1) {
1541 anObject = appendProxyData(aProtocol, address, v[0]);
1544 attributesToFilter.
append(kTTSym_service, none);
1547 if (xmlTextReaderMoveToAttribute((xmlTextReaderPtr)aXmlHandler->mReader, (
const xmlChar*)(
"type")) == 1) {
1549 aXmlHandler->
fromXmlChar(xmlTextReaderValue((xmlTextReaderPtr)aXmlHandler->mReader), v);
1551 if (v.
size() == 1) {
1556 anObject.
set(kTTSym_type, v);
1559 attributesToFilter.
append(kTTSym_type, none);
1567 else if (objectName == kTTSym_Container) {
1570 anObject = appendProxyContainer(aProtocol, address);
1573 else if (objectName == kTTSymEmpty ||
1574 objectName == kTTSym_none)
1582 this->mDirectory->
TTNodeCreate(address, empty, NULL, &aNode, &newInstanceCreated);
1589 if (anObject.
valid()) {
1592 if (mType == kTTSym_mirror) {
1595 TTValue attributesToCache, v, args, none;
1599 mCachedAttributes.
getKeys(attributesToCache);
1600 for (
TTUInt32 i = 0; i < attributesToCache.
size(); i++) {
1602 cachedAttribute = attributesToCache[i];
1608 args = cachedAttribute;
1609 anObject.
send(
"AttributeCache", args);
1615 xmlTextReaderMoveToFirstAttribute((xmlTextReaderPtr)aXmlHandler->mReader);
1620 aXmlHandler->
fromXmlChar(xmlTextReaderName((xmlTextReaderPtr)aXmlHandler->mReader), v);
1622 if (v.
size() == 1) {
1626 attributeName = v[0];
1629 if (!attributesToFilter.
lookup(attributeName, none))
1633 aXmlHandler->
fromXmlChar(xmlTextReaderValue((xmlTextReaderPtr)aXmlHandler->mReader), v);
1636 anObject.
set(attributeName, v);
1639 }
while (xmlTextReaderMoveToNextAttribute((xmlTextReaderPtr)aXmlHandler->mReader) == 1);
1648 mTempAddress = mTempAddress.
getParent();
1653 mTempAddress = mTempAddress.
getParent();
1656 TTErr TTApplication::ProxyDataInstantiate(
const TTValue& inputValue,
TTValue& outputValue)
1659 if (mType == kTTSym_proxy) {
1663 TTSymbol protocolName = protocolNames[0];
1668 if (inputValue.
size() == 2) {
1676 outputValue = appendProxyData(aProtocol, address.
normalize(), service);
1690 TTBoolean newInstanceCreated, allowGetRequest, allowSetRequest, allowListenRequest;
1691 TTObject getAttributeCallback, setAttributeCallback, sendMessageCallback, listenAttributeCallback;
1695 if (objectName != kTTSymEmpty && objectName != kTTSym_none) {
1697 TTValue none, v, args = objectName;
1701 if (allowGetRequest) {
1703 getAttributeCallback =
TTObject(
"callback");
1706 getAttributeCallback.
set(kTTSym_baton, baton);
1708 args.
append(getAttributeCallback);
1715 if (allowSetRequest) {
1717 setAttributeCallback =
TTObject(
"callback");
1720 setAttributeCallback.
set(kTTSym_baton, baton);
1722 args.
append(setAttributeCallback);
1724 sendMessageCallback =
TTObject(
"callback");
1727 sendMessageCallback.
set(kTTSym_baton, baton);
1729 args.
append(sendMessageCallback);
1739 if (allowListenRequest) {
1741 listenAttributeCallback =
TTObject(
"callback");
1744 listenAttributeCallback.
set(kTTSym_baton, baton);
1746 args.
append(listenAttributeCallback);
1751 aMirror =
TTObject(kTTSym_Mirror, args);
1756 aMirror.
send(
"AttributesInstantiate", attributesName);
1759 this->mDirectory->
TTNodeCreate(anAddress, aMirror, NULL, &aNode, &newInstanceCreated);
1772 aData =
TTObject(kTTSym_Data, service);
1775 aData.
set(kTTSym_baton, baton);
1779 if (this->mDirectory->
getTTNode(anAddress, &aNode))
1782 this->mDirectory->
TTNodeCreate(anAddress, aData, NULL, &aNode, &newInstanceCreated);
1797 aContainer =
TTObject(kTTSym_Container);
1800 this->mDirectory->
TTNodeCreate(anAddress, aContainer, aContainer.
instance(), &aNode, &newInstanceCreated);
1807 #pragma mark Some Methods
TTErr sendMessage(const TTSymbol name)
TODO: Document this function.
TTAddress appendAddress(const TTAddress &toAppend)
Return a new TTAddress with the appended part.
TTErr(TTObjectBase::* TTSetterMethod)(const TTAttribute &attribute, const TTValue &value)
A type that can be used to store a pointer to a message for an object.
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
TTErr TT_EXTENSION_EXPORT TTProtocolSetAttributeCallback(const TTValue &baton, const TTValue &data)
TTErr registerObserverForNotifications(const TTObject &observingObject)
Register an observer.
TTErr send(const TTSymbol aName)
Send a message to this object with no arguments.
TTAddress appendAttribute(TTSymbol anAttribute)
Return a new TTAddress with attribute part.
TTErr unregisterObserverForNotifications(const TTObject &observingObject)
Unregister an observer for notifications.
TTSymbol & getName()
Get the name of the node.
TTString toString(TTBoolean quotes=YES) const
Return the content as a single string with spaces between elements.
virtual TTErr SendGetRequest(TTSymbol to, TTAddress address, TTValue &returnedValue, TTUInt8 tryCount=0)=0
TTErr lookup(const TTSymbol key, TTValue &value)
Find the value for the given key.
TTErr TTNodeCreate(TTAddress &anAddress, TTObject &newObject, void *aContext, TTNodePtr *returnedTTNode, TTBoolean *nodeCreated)
Create a new TTNode, at the given location in the tree.
TTErr fromXmlChar(const void *xCh, TTValue &v, TTBoolean addQuote=NO, TTBoolean numberAsSymbol=NO)
TTXmlReader make a TTValue from an xmlChar* using the fromString method (see in TTValue.h)
#define addAttribute(name, type)
A convenience macro to be used by subclasses for registering attributes with a custom getter...
We build a directory of TTNodes, and you can request a pointer for any TTNode, or add an observer to ...
void copyFrom(const TTValue &obj, TTUInt16 index)
Copy a value starting from an index until the last element.
TTErr setObject(TTObject anObject=TTObject())
Set the object of the node.
TTAddress getParent()
Get a pointer to the parent address.
TTSymbol getName() const
Return the name of this class.
const char * c_str() const
Return a pointer to the internal C-string.
TTNodePtr getRoot()
Get the root of the TTNodeDirectory.
The TTAddress class is used to represent a string and efficiently pass and compare that string...
Create and use Jamoma object instances.
TTProtocol is the base class for all protocol protocol.
TTObject & getObject()
Get the object binded by this node.
size_type size() const noexcept
Return the number of elements.
TTAddress appendInstance(const TTSymbol anInstance)
Return a new TTAddress with a instance part.
TTErr sendNotification(const TTSymbol name, const TTValue &arguments)
Send a notification.
TTErr getAttributeValue(const TTSymbol name, TTValue &value)
Get an attribute value for an object.
TTAddress normalize()
Normalize an address for lookup and other directory operations This would return an address without d...
this flag means that an address have no leading slash
TTErr getKeys(TTValue &hashKeys)
Get an array of all of the keys for the hash table.
This class represents a single attribute, as used by the TTObjectBase class.
Handles application namespace using a TTNodeDirectory and two tables to convert any TTName into a spe...
TTBoolean mXmlNodeIsEmpty
true if the Node is empty
Base class for all first-class Jamoma objects.
TTErr TTNodeRemove(TTAddress &anAddress)
Remove a TTNodefrom the directory.
Maintain a collection of TTValue objects indexed by TTSymbol pointers.
TTErr Lookup(TTAddress anAddress, TTList &returnedTTNodes, TTNodePtr *firstReturnedTTNode)
Find TTNodes by address.
This is a special type used by TTAttribute to indicate that a value is a TTValue and is locally maint...
TTErr setName(TTSymbol aname)
Set the name of the TTNodeDirectory.
void append(const T &anElementValueToAppend)
Insert a single TTElement at the end.
#define addAttributeWithGetter(name, type)
A convenience macro to be used by subclasses for registering attributes with a custom getter...
void * TTPtr
A generic pointer.
TTErr get(const TTSymbol aName, T &aReturnedValue) const
Get an attribute value for an object.
TTMODULAR_EXPORT TTApplicationManagerPtr TTModularApplicationManager
Export a pointer to a TTApplicationManager instance.
TTSymbol name() const
Return the name of this class.
TTErr TTApplicationProxyDataValueCallback(const TTValue &baton, const TTValue &data)
A callback used by proxy data (see in appendData method)
TTSymbol & getInstance()
Get the instance of the node.
#define addAttributeProperty(attributeName, propertyName, initialValue)
A convenience macro to be used for registering properties of attributes.
virtual TTErr SendListenRequest(TTSymbol to, TTAddress address, TTBoolean enable, TTUInt8 tryCount=0)=0
TTErr set(const TTSymbol aName, T aValue)
Set an attribute value for an object.
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
TTErr append(const TTSymbol key, const TTValue &value)
Insert an item into the hash table.
TTErr addObserverForNotifications(TTAddress anAddress, TTObject &anObserver, TTInt8 maxDepthDifference=-1)
Add a TTCallback as a life cycle observer of all nodes below this one.
TTBoolean mXmlNodeStart
true if the Reader starts to read a Node
#define accessApplicationLocal
Access to local application.
Boolean (1/0) or (true/false) flag.
#define accessApplicationProtocolNames(applicationName)
Access to all protocol names of an application.
TTBoolean isEmpty()
Return true if the hash has nothing stored in it.
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.
TTSymbol & getAttribute()
Get the attribute part.
TTSymbol getNameInstance()
Get the name.instance part.
#define addMessageWithArguments(name)
A convenience macro to be used by subclasses for registering messages.
this flag means that address1 refers to a node at a lower level than address2 in the tree structure ...
const char * c_str() const
Return a pointer to the internal string as a C-string.
std::int32_t TTInt32
32 bit signed integer
TTErr clear()
Remove all items from the hash table.
virtual TTErr SendDiscoverRequest(TTSymbol to, TTAddress address, TTSymbol &returnedType, TTValue &returnedChildren, TTValue &returnedAttributes, TTUInt8 tryCount=0)=0
TTErr TT_EXTENSION_EXPORT TTProtocolDirectoryCallback(const TTValue &baton, const TTValue &data)
Called when an application directory send a notification to registered application observers...
TTErr TT_EXTENSION_EXPORT TTProtocolListenAttributeCallback(const TTValue &baton, const TTValue &data)
TTAddressComparisonFlag
Comparison flags between address returned by address1->compare(address2).
TTErr getAddress(TTAddress &returnedAddress, TTAddress from=kTTAdrsEmpty)
Get the address of the node.
TTErr TT_EXTENSION_EXPORT TTProtocolAttributeCallback(const TTValue &baton, const TTValue &data)
Called when an application object attribute send a notification to registered application observers...
32-bit signed integer, range is -2,147,483,648 through 2,147,483,647.
void TTFOUNDATION_EXPORT TTLogMessage(TTImmutableCString message,...)
Platform and host independent method for posting log messages.
Something went wrong, but what exactly is not known. Typically used for context-specific problems...
friend TTErr TTMODULAR_EXPORT TTApplicationProxyDataValueCallback(const TTValue &baton, const TTValue &data)
A callback used by proxy data (see in appendData method)
TTAddressType getType()
Get the type.
TTErr remove(const TTSymbol key)
Remove an item from the hash table.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
signed char TTInt8
8 bit signed integer (char)
TTErr removeObserverForNotifications(TTAddress anAddress, TTObject &anObserver)
Remove a TTCallback as a life cycle observer of all nodes below this one.
void attributes(TTValue &returnedAttributeNames) const
Return a list of names of the available attributes.
TTErr init()
Initialize the TTNodeDirectory.
TTSymbol mXmlNodeName
the Node name being read by the Reader
std::uint32_t TTUInt32
32 bit unsigned integer
TTErr splitAt(TTUInt32 whereToSplit, TTAddress &returnedPart1, TTAddress &returnedPart2)
A parsing tool : split address in two part from a given '/' position.
TTErr TT_EXTENSION_EXPORT TTProtocolGetAttributeCallback(const TTValue &baton, const TTValue &data)
TTErr sethidden(const TTValue &newHiddenFlag)
Set the hidden flag for the attribute, determining if this attribute is private/invisible to the outs...
#define addAttributeWithSetter(name, type)
A convenience macro to be used by subclasses for registering attributes with a custom setter...
TTErr TT_EXTENSION_EXPORT TTProtocolSendMessageCallback(const TTValue &baton, const TTValue &data)
#define addMessage(name)
A convenience macro to be used by subclasses for registering messages.
TODO : how to have TTGetterMethod and TTSetterMethod for Mirror message Property ?
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 the...
TTObjectBase * instance() const
Return a direct pointer to the internal instance.
TTAddressComparisonFlag compare(const TTAddress &toCompare, TTInt8 &depthDifference)
A comparison tool.
The TTString class is used to represent a string.
TTUInt32 countSeparator()
A parsing tool : count how many C_SEPARATOR there is in the address.
TTBoolean valid() const
Determine if the object contained by this TTObject is truly ready for use.
TTErr(TTObjectBase::* TTGetterMethod)(const TTAttribute &attribute, TTValue &value)
A type that can be used to store a pointer to a message for an object.
We build a tree of TTNodes, and you can request a pointer for any TTNode, or add an observer to any T...
#define accessProtocol(protocolName)
Access to a protocol by name.
TTErr setNameInstance(TTAddress &aNameInstance, TTSymbol &newInstance, TTBoolean *newInstanceCreated)
Set the name and the instance of the node.
[doxygenAppendixC_copyExample]
virtual TTErr SendSetRequest(TTSymbol to, TTAddress address, TTValue &value, TTUInt8 tryCount=0)=0
TTErr getTTNode(const char *anAddress, TTNodePtr *returnedTTNode)
Given an address, return a pointer to a TTNode.
TTErr findAttribute(const TTSymbol name, TTAttribute **attr)
Find an attribute.
unsigned char TTUInt8
8 bit unsigned integer (char)
#define addMessageProperty(messageName, propertyName, initialValue)
A convenience macro to be used for registering properties of messages.