Jamoma API  0.6.0.a19
Minuit.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup modularMinuit
4  *
5  * @brief It's the Minuit protocol which use the Open Sound Control protocol
6  *
7  * @details
8  *
9  * @authors Laurent Garnier, Theo Delahogue
10  *
11  * @copyright © 2011, LaBRI (http://www.labri.fr) - BlueYeti (http://www.blueyeti.fr) - GMEA (http://www.gmea.net) @n
12  * This code is licensed under the terms of the CeCILL-C license as circulated by CEA, CNRS and INRIA at the following URL @n
13  * http://www.cecill.info
14  */
15 
16 
17 /*
18  Copyright:
19  LaBRI (http://www.labri.fr) - BlueYeti (http://www.blueyeti.fr) - GMEA (http://www.gmea.net)
20 
21  Author(s): Laurent Garnier, Theo Delahogue
22  Last modification: 16/08/2011
23 
24  Adviser(s):
25  Myriam Desainte-Catherine (myriam.desainte-catherine@labri.fr)
26 
27  This software is a computer program whose purpose is to propose
28  a library for interactive scores edition and execution.
29 
30  This software is governed by the CeCILL-C license under French law and
31  abiding by the rules of distribution of free software. You can use,
32  modify and/ or redistribute the software under the terms of the CeCILL-C
33  license as circulated by CEA, CNRS and INRIA at the following URL
34  "http://www.cecill.info".
35 
36  As a counterpart to the access to the source code and rights to copy,
37  modify and redistribute granted by the license, users are provided only
38  with a limited warranty and the software's author, the holder of the
39  economic rights, and the successive licensors have only limited
40  liability.
41 
42  In this respect, the user's attention is drawn to the risks associated
43  with loading, using, modifying and/or developing or reproducing the
44  software by the user in light of its specific status of free software,
45  that may mean that it is complicated to manipulate, and that also
46  therefore means that it is reserved for developers and experienced
47  professionals having in-depth computer knowledge. Users are therefore
48  encouraged to load and test the software's suitability as regards their
49  requirements in conditions enabling the security of their systems and/or
50  data to be ensured and, more generally, to use and operate it in the
51  same conditions as regards security.
52 
53  The fact that you are presently reading this means that you have had
54  knowledge of the CeCILL-C license and that you accept its terms.
55  */
56 
57 
58 #include "TTProtocol.h"
59 #include "Minuit.h"
60 
61 #define thisTTClass Minuit
62 #define thisTTClassName "Minuit"
63 #define thisTTClassTags "network, protocol, minuit"
64 
65 #define thisProtocolVersion "0.3"
66 #define thisProtocolAuthor "Raphael Marczak/Laurent Garnier/Theo de la Hogue"
67 #define thisProtocolGet YES
68 #define thisProtocolSet YES
69 #define thisProtocolListen YES
70 #define thisProtocolDiscover YES
71 #define thisProtocolDiscoverAll NO
72 
73 extern "C" TT_EXTENSION_EXPORT TTErr TTLoadJamomaExtension_Minuit(void)
74 {
75  TTFoundationInit();
76  Minuit::registerClass();
77  return kTTErrNone;
78 }
79 
81 mAnswerManager(NULL),
82 mSenderManager(NULL)
83 {
85 
88 
89  addMessageWithArguments(receivedMessage);
90  addMessageProperty(receivedMessage, hidden, YES);
91 }
92 
93 Minuit::~Minuit()
94 {
95  if (mAnswerManager)
96  delete mAnswerManager;
97 
98  if (mSenderManager)
99  delete mSenderManager;
100 }
101 
102 TTErr Minuit::Scan(const TTValue& inputValue, TTValue& outputValue)
103 {
104  // TODO
105  return kTTErrGeneric;
106 }
107 
108 /*!
109  * Run the reception thread
110  *
111  */
112 TTErr Minuit::Run(const TTValue& inputValue, TTValue& outputValue)
113 {
114  TTValue v;
115  TTUInt16 port;
116  TTErr err;
117 
118  // Minuit doesn't need a thread per application
119  if (inputValue.size())
120  return kTTErrGeneric;
121 
122  if (!mRunning) {
123 
124  mAnswerManager = new MinuitAnswerManager((MinuitPtr)this);
125  mSenderManager = new MinuitSenderManager();
126 
127  mOscReceive = TTObject("osc.receive");
128 
129  if (mOscReceive.valid()) {
130 
131  TTObject minuitProtocol(this);
132 
133  // select local application to get its port parameter
134  ApplicationSelectLocal();
135  minuitProtocol.get("port", v);
136 
137  if (v.size()) {
138 
139  port = v[0];
140 
141  err = mOscReceive.set("port", v);
142 
143  if (!err) {
144 
145  mOscReceive.registerObserverForNotifications(minuitProtocol); // using our 'receivedMessage' method
146 
147  mRunning = YES;
148 
149  TTLogMessage("Minuit::Run : connected to port %ld\n", port);
150 
151  return kTTErrNone;
152  }
153  else {
154 
155  // return the port
156  outputValue = port;
157 
158  TTLogError("Minuit::Run : unable to connect to port %ld\n", port);
159  }
160  }
161  }
162  }
163 
164  return kTTErrGeneric;
165 }
166 
167 /*!
168  * Stop the reception thread
169  *
170  */
171 TTErr Minuit::Stop(const TTValue& inputValue, TTValue& outputValue)
172 {
173  // Minuit doesn't need a thread per application
174  if (inputValue.size())
175  return kTTErrGeneric;
176 
177  if (mRunning) {
178 
179  delete mAnswerManager;
180  mAnswerManager = NULL;
181 
182  delete mSenderManager;
183  mSenderManager = NULL;
184 
185  TTObject minuitProtocol(this);
186 
187  mOscReceive.unregisterObserverForNotifications(minuitProtocol);
188  mOscReceive = TTObject();
189 
190  mRunning = NO;
191 
192  return kTTErrNone;
193  }
194 
195  return kTTErrGeneric;
196 }
197 
198 /**************************************************************************************************************************
199  *
200  * SEND REQUEST METHODS
201  *
202  **************************************************************************************************************************/
203 
204 /*!
205  * Send a discover request to an application to get a part of the namespace at the given address
206  *
207  * \param to : the application where to discover
208  * \param address : the address to discover
209  * \param returnedType : the type of the node at the address (default is none which means no type)
210  * \param returnedChildren : all names of nodes below the address
211  * \param returnedAttributes : all attributes the node at the address
212  * \return errorcode : kTTErrNone means the answer has been received, kTTErrValueNotFound means something is bad in the request
213  else it returns kTTErrGeneric if no answer or timeout
214  */
215 TTErr Minuit::SendDiscoverRequest(TTSymbol to, TTAddress address,
216  TTSymbol& returnedType,
217  TTValue& returnedChildren,
218  TTValue& returnedAttributes,
219  TTUInt8 tryCount)
220 {
221  TTValue arguments, answer;
222  TTString header;
223  TTInt32 state;
224 
225  // edit header "localAppName?namespace"
226  header = mLocalApplicationName.c_str();
227  header += MINUIT_REQUEST_DISCOVER;
228 
229  // edit arguments <header address>
230  arguments = TTValue(address);
231 
232  if (!sendMessage(to, TTSymbol(header), arguments)) {
233 
234 #ifdef TT_PROTOCOL_DEBUG
235  std::cout << "Minuit : applicationSendDiscoverRequest " << std::endl;
236 #endif
237 
238  // Wait for an answer
239  mAnswerManager->AddDiscoverAnswer(to, address);
240 
241  state = NO_ANSWER;
242  do
243  {
244  state = mAnswerManager->CheckDiscoverAnswer(to, address, answer);
245  }
246  while (state == NO_ANSWER);
247 
248  if (state == ANSWER_RECEIVED)
249  return mAnswerManager->ParseDiscoverAnswer(answer, returnedType, returnedChildren, returnedAttributes);
250 
251  else if (state == TIMEOUT_EXCEEDED && tryCount < MAX_TRY)
252  return SendDiscoverRequest(to, address, returnedType, returnedChildren, returnedAttributes, tryCount+1);
253  }
254 
255  return kTTErrGeneric;
256 }
257 
258 /*!
259  * Send a discover all request to an application to fill all the directory under this address
260  *
261  * \param to : the application where to discover
262  * \param address : the address to discover
263  * \param node : the node for this address
264  * \param tryCount : number of try for this request
265  * \return errorcode : kTTErrNone means the answer has been received, kTTErrValueNotFound means something is bad in the request
266  else it returns kTTErrGeneric if no answer or timeout
267  */
268 TTErr Minuit::SendDiscoverAllRequest(TTSymbol to, TTAddress address, TTNodePtr node, TTUInt8 tryCount)
269 {
270  return kTTErrGeneric;
271 }
272 
273 /*!
274  * Send a get request to an application to get a value at the given address
275  *
276  * \param to : the application where to get
277  * \param address : the address to get
278  * \param returnedValue : the value which is going to be filled
279  * \return errorcode : kTTErrNone means the answer has been received, kTTErrValueNotFound means something is bad in the request
280  else it returns kTTErrGeneric if no answer or timeout
281  */
282 TTErr Minuit::SendGetRequest(TTSymbol to, TTAddress address,
283  TTValue& returnedValue,
284  TTUInt8 tryCount)
285 {
286  TTValue v, arguments;
287  TTString header;
288  TTInt32 state;
289 
290  // edit header "localAppName?get"
291  header = mLocalApplicationName.c_str();
292  header += MINUIT_REQUEST_GET;
293 
294  // edit arguments <header address>
295  arguments = TTValue(address);
296 
297  if (!sendMessage(to, TTSymbol(header), arguments)) {
298 
299 #ifdef TT_PROTOCOL_DEBUG
300  std::cout << "Minuit : applicationSendGetRequest " << std::endl;
301 #endif
302 
303  // Wait for an answer
304  mAnswerManager->AddGetAnswer(to, address);
305 
306  state = ANSWER_RECEIVED;
307  do
308  {
309  state = mAnswerManager->CheckGetAnswer(to, address, returnedValue);
310  }
311  while(state == NO_ANSWER);
312 
313  if (state == ANSWER_RECEIVED)
314  return kTTErrNone;
315 
316  else if (state == TIMEOUT_EXCEEDED && tryCount < MAX_TRY)
317  return SendGetRequest(to, address, returnedValue, tryCount+1);
318 
319  }
320 
321  return kTTErrGeneric;
322 }
323 
324 /*!
325  * Send a set request to set a value of a specific application
326  *
327  * \param to : the application where to set
328  * \param address : the address to set
329  * \param value : anything to send
330  * \return errorcode : kTTErrNone means the answer has been received, kTTErrValueNotFound means something is bad in the request
331  */
332 TTErr Minuit::SendSetRequest(TTSymbol to, TTAddress address,
333  TTValue& value,
334  TTUInt8 tryCount)
335 {
336 
337 #ifdef TT_PROTOCOL_DEBUG
338  std::cout << "Minuit : applicationSendSetRequest " << std::endl;
339 #endif
340 
341  if (address.getAttribute() == kTTSym_value)
342  return sendMessage(to, address.removeAttribute(), value);
343  else
344  return sendMessage(to, address, value);
345 }
346 
347 /*!
348  * Send a listen request to a specific application
349  *
350  * \param to : the application where to listen
351  * \param address : the address to listen
352  * \param enable : enable/disable the listening
353  * \return errorcode : kTTErrNone means the answer has been received, kTTErrValueNotFound means something is bad in the request
354  */
355 TTErr Minuit::SendListenRequest(TTSymbol to, TTAddress address,
356  TTBoolean enable,
357  TTUInt8 tryCount)
358 {
359  TTValue v, arguments;
360  TTString header;
361 
362  // edit header "appName?listen"
363  header = mLocalApplicationName.c_str();
364  header += MINUIT_REQUEST_LISTEN;
365 
366  // edit arguments <header address, enable>
367  arguments = TTValue(address);
368 
369  if (enable)
370  arguments.append(TTSymbol(MINUIT_REQUEST_LISTEN_ENABLE));
371  else
372  arguments.append(TTSymbol(MINUIT_REQUEST_LISTEN_DISABLE));
373 
374 #ifdef TT_PROTOCOL_DEBUG
375  std::cout << "Minuit : applicationSendListenRequest " << std::endl;
376 #endif
377 
378  return sendMessage(to, TTSymbol(header), arguments);
379 }
380 
381 
382 /**************************************************************************************************************************
383  *
384  * SEND ANSWER METHODS
385  *
386  **************************************************************************************************************************/
387 
388 /*!
389  * Send a disover answer to a application which ask for.
390  *
391  * \param to : the application where to send answer
392  * \param address : the address where comes from the description
393  * \param returnedType : the type of the node at the address (default is none which means no type)
394  * \param returnedChildren : all names of nodes below the address
395  * \param returnedAttributes : all attributes the node at the address
396  */
397 TTErr Minuit::SendDiscoverAnswer(TTSymbol to, TTAddress address,
398  TTSymbol& returnedType,
399  TTValue& returnedChildren,
400  TTValue& returnedAttributes,
401  TTErr err)
402 {
403  TTValue v, arguments;
404  TTString header;
405 
406  // edit header "appName:get"
407  if (!err) {
408  header = mLocalApplicationName.c_str();
409  header += MINUIT_ANSWER_DISCOVER;
410  }
411  else {
412  header = mLocalApplicationName.c_str();
413  header += MINUIT_ERROR_DISCOVER;
414  }
415 
416  // edit arguments merging all returned fields
417  // note : here we need to begin by the end
418  // and then prepend fields one by one
419  if (returnedAttributes.size()) {
420  arguments = returnedAttributes;
421  arguments.prepend(TTSymbol(MINUIT_START_ATTRIBUTES));
422  arguments.append(TTSymbol(MINUIT_END_ATTRIBUTES));
423  }
424 
425  if (returnedChildren.size()) {
426  // if no attribute fields
427  if (arguments.size()) {
428  arguments.prepend(TTSymbol(MINUIT_END_NODES));
429  arguments.prepend(returnedChildren);
430  arguments.prepend(TTSymbol(MINUIT_START_NODES));
431  }
432  else {
433  arguments = returnedChildren;
434  arguments.prepend(TTSymbol(MINUIT_START_NODES));
435  arguments.append(TTSymbol(MINUIT_END_NODES));
436  }
437  }
438 
439  if (arguments.size()) {
440  arguments.prepend(returnedType);
441  arguments.prepend(address);
442  }
443  else {
444  arguments = TTValue(address);
445  arguments.append(returnedType);
446  }
447 
448 #ifdef TT_PROTOCOL_DEBUG
449  std::cout << "Minuit : applicationSendDiscoverAnswer " << std::endl;
450 #endif
451 
452  return sendMessage(to, TTSymbol(header), arguments);
453 }
454 
455 /*!
456  * Send a disover answer to a application which ask for.
457  *
458  * \param to : the application where to send answer
459  * \param address : the address where comes from the description
460  * \param node : the node for this address
461  */
462 TTErr Minuit::SendDiscoverAllAnswer(TTSymbol to, TTAddress address, TTNodePtr node, TTErr err)
463 {
464  return kTTErrGeneric;
465 }
466 
467 /*!
468  * Send a get answer to an application which ask for.
469  *
470  * \param to : the application where to send answer
471  * \param address : the address where comes from the value
472  * \param returnedValue : the value of the attribute at the address
473  */
474 TTErr Minuit::SendGetAnswer(TTSymbol to, TTAddress address,
475  const TTValue& returnedValue,
476  TTErr err)
477 {
478  TTValue v, arguments;
479  TTString header;
480 
481  // edit header "appName:get"
482  if (!err) {
483  header = mLocalApplicationName.c_str();
484  header += MINUIT_ANSWER_GET;
485  }
486  else {
487  header = mLocalApplicationName.c_str();
488  header += MINUIT_ERROR_GET;
489  }
490 
491  // edit arguments copying the returned value
492  // and prepending the address
493  arguments = returnedValue;
494  arguments.prepend(address);
495 
496 #ifdef TT_PROTOCOL_DEBUG
497  std::cout << "Minuit : applicationSendGetAnswer" << std::endl;
498 #endif
499 
500  return sendMessage(to, TTSymbol(header), arguments);
501 }
502 
503 /*!
504  * Send a listen answer to an application which ask for.
505  *
506  * \param to : the application where to send answer
507  * \param address : the address where comes from the value
508  * \param returnedValue : the value of the attribute at the address
509  */
510 TTErr Minuit::SendListenAnswer(TTSymbol to, TTAddress address,
511  const TTValue& returnedValue,
512  TTErr err)
513 {
514  TTValue v, arguments;
515  TTString header, aString;
516 
517  // edit header "appName:get"
518  if (!err) {
519  header = mLocalApplicationName.c_str();
520  header += MINUIT_ANSWER_LISTEN;
521  }
522  else {
523  header = mLocalApplicationName.c_str();
524  header += MINUIT_ERROR_LISTEN;
525  }
526 
527  // edit arguments copying the returned value
528  // and prepending the address
529  arguments = returnedValue;
530  arguments.prepend(address);
531 
532 #ifdef TT_PROTOCOL_DEBUG
533  std::cout << "Minuit : applicationSendListenAnswer " << std::endl;
534 #endif
535 
536  return sendMessage(to, TTSymbol(header), arguments);
537 }
538 
539 TTErr Minuit::sendMessage(TTSymbol applicationName, TTSymbol header, TTValue& arguments)
540 {
541  if (!mSenderManager)
542  return kTTErrGeneric;
543 
544  // Check application registration
545  TTValue v;
546  TTErr err = mApplicationParameters.lookup(applicationName, v);
547 
548  if (!err)
549  {
550  TTHashPtr parameters = TTHashPtr((TTPtr)v[0]);
551  TTValue vIp, vPort;
552  TTErr errIp = parameters->lookup(TTSymbol("ip"), vIp);
553  TTErr errPort = parameters->lookup(TTSymbol("port"), vPort);
554 
555  if (errIp || errPort)
556  return kTTErrGeneric;
557 
558  TTValue message(header);
559  message.append((TTPtr)&arguments);
560 
561  err = mSenderManager->send(applicationName, vIp, vPort, message);
562 
563  if (err)
564  {
565  ; // can't send message to the application because the osc.sender is busy
566  ; // TODO : have bundle system
567  }
568 
569  else if (mActivity)
570  {
571  v = arguments;
572  v.prepend(header);
573  ActivityOutMessage(v);
574  }
575  }
576 
577  return err;
578 }
579 
580 TTErr Minuit::receivedMessage(const TTValue& message, TTValue& outputValue)
581 {
582  TTSymbol aSymbol, sender, operation;
583  TTString headerString;
584  TTInt32 operationStart;
585  TTValue arguments;
586  TTAddress whereTo = kTTAdrsEmpty;
587  TTValue v;
588  TTErr err;
589 
590  /*
591  if message starts with '/'
592 
593  else if first element contains '?'
594  parse sender?operation /whereTo
595 
596  if ?namespace
597 
598  if ?get
599 
600  if ?listen
601 
602  else if first element contains ':'
603  parse sender:operation /whereTo
604  get arguments
605 
606  if :namespace
607 
608  if :get
609 
610  if :listen
611 
612  */
613 
614  if (mActivity) ActivityInMessage(message);
615 
616  aSymbol = message[0];
617  headerString = aSymbol.string();
618 
619 #ifdef TT_PROTOCOL_DEBUG
620  cout << "Message header is " << aSymbol.c_str() << endl;
621 #endif
622 
623  // if message starts with '/'
624  if (headerString[0] == '/')
625  {
626  aSymbol = message[0];
627  whereTo = TTAddress(aSymbol.c_str());
628 
629  arguments.copyFrom(message, 1);
630 
631 #ifdef TT_PROTOCOL_DEBUG
632  cout << "Receive set request at " << whereTo.c_str() << endl;
633 #endif
634 
635  return ReceiveSetRequest(kTTSymEmpty, whereTo, arguments);
636  }
637  else {
638 
639  // Is it a request ?
640  operationStart = headerString.find_first_of('?');
641  if (operationStart >= 0)
642  {
643  // parse sender application
644  sender = TTSymbol(headerString.substr(0, operationStart));
645 
646  // Check the sender application registration
647  err = mApplicationParameters.lookup(sender, v);
648  if (!err) {
649 
650  // parse request
651  operation = TTSymbol(headerString.substr(operationStart, headerString.size() - operationStart));
652 
653  // parse /whereTo
654  if (message[1].type() == kTypeSymbol) {
655  aSymbol = message[1];
656  whereTo = TTAddress(aSymbol.c_str());
657  }
658 
659 #ifdef TT_PROTOCOL_DEBUG
660  cout << "Receive " << operation.c_str() << " request from "<< sender.c_str() << " at " << whereTo.c_str() << endl;
661 #endif
662 
663  // switch on request
664  if (operation == TTSymbol(MINUIT_REQUEST_DISCOVER))
665  return ReceiveDiscoverRequest(sender, whereTo);
666 
667  else if (operation == TTSymbol(MINUIT_REQUEST_GET))
668  return ReceiveGetRequest(sender, whereTo);
669 
670  else if (operation == TTSymbol(MINUIT_REQUEST_LISTEN)) {
671 
672  // parse enable/disable
673  if (message[2].type() == kTypeSymbol) {
674  message.get(2, aSymbol);
675 
676  if (aSymbol == TTSymbol(MINUIT_REQUEST_LISTEN_ENABLE))
677  return ReceiveListenRequest(sender, whereTo, true);
678 
679  else if (aSymbol == TTSymbol(MINUIT_REQUEST_LISTEN_DISABLE))
680  return ReceiveListenRequest(sender, whereTo, false);
681 
682  else
683  ; // TODO send bad request error notification
684  }
685  }
686  }
687 
688  }// end if starts by '?'
689 
690  // Is it a answer :
691  operationStart = headerString.find_first_of(':');
692  if (operationStart >= 0)
693  {
694  // parse sender application
695  sender = TTSymbol(headerString.substr(0, operationStart));
696 
697  // Check the sender application registration
698  err = mApplicationParameters.lookup(sender, v);
699  if (!err) {
700 
701  // parse request
702  operation = TTSymbol(headerString.substr(operationStart, headerString.size() - operationStart));
703 
704  // parse /whereTo
705  if (message[1].type() == kTypeSymbol) {
706  aSymbol = message[1];
707  whereTo = TTAddress(aSymbol.c_str());
708  }
709 
710 #ifdef TT_PROTOCOL_DEBUG
711  cout << "Receive " << operation.c_str() << " answer from "<< sender.c_str() << " at " << whereTo.c_str() << endl;
712 #endif
713 
714  arguments.copyFrom(message, 2);
715 
716  // switch on answer
717  if (operation == TTSymbol(MINUIT_ANSWER_DISCOVER))
718  return mAnswerManager->ReceiveDiscoverAnswer(sender, whereTo, arguments);
719 
720  else if (operation == TTSymbol(MINUIT_ANSWER_GET))
721  return mAnswerManager->ReceiveGetAnswer(sender, whereTo, arguments);
722 
723  else if (operation == TTSymbol(MINUIT_ANSWER_LISTEN))
724  return ReceiveListenAnswer(sender, whereTo, arguments);
725 
726  }
727  } // end if starts by ':'
728 
729  // Is it an error :
730  operationStart = headerString.find_first_of('!');
731  if (operationStart >= 0)
732  {
733  // parse sender application
734  sender = TTSymbol(headerString.substr(0, operationStart));
735 
736  // Check the sender application registration
737  err = mApplicationParameters.lookup(sender, v);
738  if (!err) {
739 
740  // parse operation
741  operation = TTSymbol(headerString.substr(operationStart, headerString.size() - operationStart));
742 
743  // parse /whereTo
744  if (message[1].type() == kTypeSymbol) {
745  aSymbol = message[1];
746  whereTo = TTAddress(aSymbol.c_str());
747  }
748 
749 #ifdef TT_PROTOCOL_DEBUG
750  cout << "Receive " << operation.c_str() << " error from "<< sender.c_str() << " at " << whereTo.c_str() << endl;
751 #endif
752  if (message.size() > 2)
753  arguments.copyFrom(message, 2);
754 
755  // switch on answer
756  if (operation == TTSymbol(MINUIT_ERROR_DISCOVER))
757  return mAnswerManager->ReceiveDiscoverAnswer(sender, whereTo, arguments, kTTErrGeneric);
758 
759  else if (operation == TTSymbol(MINUIT_ERROR_GET))
760  return mAnswerManager->ReceiveGetAnswer(sender, whereTo, arguments, kTTErrGeneric);
761 
762  // théo - is there error for listen request ?
763  }
764  } // end if starts by ':'
765 
766  } // end else
767 
768  return kTTErrNone;
769 }
TTErr sendMessage(const TTSymbol name)
TODO: Document this function.
It's the Minuit protocol which use the Open Sound Control protocol.
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
Definition: TTBase.h:167
std::uint16_t TTUInt16
16 bit unsigned integer
Definition: TTBase.h:176
#define TT_PROTOCOL_INITIALIZE
Declares all members needed by any protocol class.
Definition: TTProtocol.h:31
TTErr lookup(const TTSymbol key, TTValue &value)
Find the value for the given key.
Definition: TTHash.cpp:76
We build a directory of TTNodes, and you can request a pointer for any TTNode, or add an observer to ...
Definition: TTNode.h:59
void copyFrom(const TTValue &obj, TTUInt16 index)
Copy a value starting from an index until the last element.
Definition: TTValue.h:147
const char * c_str() const
Return a pointer to the internal C-string.
Definition: TTString.h:83
The TTAddress class is used to represent a string and efficiently pass and compare that string...
Definition: TTAddress.h:29
Create and use Jamoma object instances.
Definition: TTObject.h:29
size_type size() const noexcept
Return the number of elements.
Maintain a collection of TTValue objects indexed by TTSymbol pointers.
Definition: TTHash.h:36
Symbol type.
Definition: TTBase.h:282
16-bit unsigned integer, range is 0 through 65,535.
Definition: TTBase.h:276
void prepend(const TTValue &aValueToPrepend)
Insert another TTValue before the first element.
Definition: TTValue.h:162
void append(const T &anElementValueToAppend)
Insert a single TTElement at the end.
Definition: TTValue.h:243
void * TTPtr
A generic pointer.
Definition: TTBase.h:248
A Protocol interface.
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
void TTFOUNDATION_EXPORT TTLogError(TTImmutableCString message,...)
Platform and host independent method for posting errors.
Definition: TTBase.cpp:572
void get(const TTUInt16 index, T &returnedElementValue) const
DEPRECATED.
Definition: TTValue.h:591
TTSymbol & getAttribute()
Get the attribute part.
Definition: TTAddress.h:130
#define addMessageWithArguments(name)
A convenience macro to be used by subclasses for registering messages.
Definition: TTMessage.h:27
TTString substr(size_t pos=0, size_t n=1) const
Returns a string object with its contents initialized to a substring of the current object...
Definition: TTString.h:342
const char * c_str() const
Return a pointer to the internal string as a C-string.
Definition: TTSymbol.h:77
std::int32_t TTInt32
32 bit signed integer
Definition: TTBase.h:177
void set(const TTUInt16 index, const T &anElementValue)
DEPRECATED.
Definition: TTValue.h:569
void TTFOUNDATION_EXPORT TTLogMessage(TTImmutableCString message,...)
Platform and host independent method for posting log messages.
Definition: TTBase.cpp:534
Something went wrong, but what exactly is not known. Typically used for context-specific problems...
Definition: TTBase.h:344
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
size_t size() const
Find out the length of a string.
Definition: TTString.h:144
size_t find_first_of(const char aChar, size_t from=0)
Return the index of the first instance of a specified char in the string.
Definition: TTString.h:296
No Error.
Definition: TTBase.h:343
#define TT_PROTOCOL_CONSTRUCTOR
Declares instantiation and registration methods to add the protocol class as any TTObject class...
Definition: TTProtocol.h:23
#define addAttributeAsProtocolParameter(name, type)
Add a protocol parameter as an attribute of the class.
Definition: TTProtocol.h:48
TTAddress removeAttribute()
Return a new TTAddress without attribute part.
Definition: TTAddress.h:155
The TTString class is used to represent a string.
Definition: TTString.h:34
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
unsigned char TTUInt8
8 bit unsigned integer (char)
Definition: TTBase.h:174
#define addMessageProperty(messageName, propertyName, initialValue)
A convenience macro to be used for registering properties of messages.
Definition: TTMessage.h:37