Jamoma API  0.6.0.a19
TTGraphOutlet.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup graphLibrary
4  *
5  * @brief Jamoma Asynchronous Object Graph Layer
6  *
7  * @details Creates a wrapper for TTObjectBases that can be used to build a control graph for asynchronous message passing
8  *
9  * @authors Timothy Place
10  *
11  * @copyright Copyright © 2010 by Timothy Place @n
12  * This code is licensed under the terms of the "New BSD License" @n
13  * http://creativecommons.org/licenses/BSD/
14  */
15 
16 
17 #ifndef __TTGRAPH_OUTLET_H__
18 #define __TTGRAPH_OUTLET_H__
19 
20 #include "TTGraph.h"
21 //#include "TTGraphObjectBase.h"
22 #include "TTGraphDestination.h"
23 
24 
25 /******************************************************************************************/
26 
27 /** This object represents a single 'outlet' from a #TTGraphObjectBase.
28  #TTGraphObjectBase maintains a vector of these outlets.
29 */
30 class TTGRAPH_EXPORT TTGraphOutlet {
31  TTGraphDestinationVector mDestinationObjects;
32 
33 public:
35  {
36  ;
37  }
38 
39  ~TTGraphOutlet()
40  {
41  ;
42  }
43 
44 
45  // Copying Functions are critical due to use by std::vector
46 
47  TTGraphOutlet(const TTGraphOutlet& original)
48  {
49  mDestinationObjects = original.mDestinationObjects;
50  }
51 
52  TTGraphOutlet& operator=(const TTGraphOutlet& original)
53  {
54  mDestinationObjects = original.mDestinationObjects;
55  return *this;
56  }
57 
58 
59  // Graph Methods
60 
61  void reset()
62  {
63  mDestinationObjects.clear();
64  }
65 
66 
67  TTErr drop(TTGraphObjectBasePtr anObject, TTUInt16 toInletNumber)
68  {
69  for (TTGraphDestinationIter dest = mDestinationObjects.begin(); dest != mDestinationObjects.end(); dest++) {
70  if (dest->match(anObject, toInletNumber)) {
71  drop(*dest);
72  break;
73  }
74  }
75  return kTTErrNone;
76  }
77 
78 
79  void drop(TTGraphDestination& aDestination)
80  {
81  TTGraphDestinationIter iter = find(mDestinationObjects.begin(), mDestinationObjects.end(), aDestination);
82 
83  if (iter != mDestinationObjects.end())
84  mDestinationObjects.erase(iter);
85  }
86 
87 
88  TTErr connect(TTGraphObjectBasePtr anObject, TTUInt16 toInletNumber)
89  {
90  TTUInt16 size = mDestinationObjects.size();
91 
92  // make sure the connection doesn't already exist
93  for (TTGraphDestinationIter destination = mDestinationObjects.begin(); destination != mDestinationObjects.end(); destination++) {
94  if (destination->match(anObject, toInletNumber))
95  return kTTErrNone;
96  }
97 
98  // create the connection
99  mDestinationObjects.resize(size+1);
100  mDestinationObjects[size].connect(anObject, toInletNumber);
101  mDestinationObjects[size].setOwner(this);
102  return kTTErrNone;
103  }
104 
105 
106  TTErr push(const TTDictionary& aDictionary)
107  {
108  for (TTGraphDestinationIter destination = mDestinationObjects.begin(); destination != mDestinationObjects.end(); destination++)
109  destination->push(aDictionary);
110  return kTTErrNone;
111  }
112 
113 };
114 
116 typedef std::vector<TTGraphOutlet> TTGraphOutletVector;
117 typedef TTGraphOutletVector::iterator TTGraphOutletIter;
118 
119 #endif // __TTGRAPH_OUTLET_H__
The TTGraphObjectBase wraps a TTDSP object such that it is possible to build a dynamic graph of audio...
std::uint16_t TTUInt16
16 bit unsigned integer
Definition: TTBase.h:176
Jamoma Asynchronous Object Graph Layer.
A type that represents the key as a C-String and the value as a pointer to the matching TTSymbol obje...
Definition: TTDictionary.h:47
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
This object represents a single 'outlet' from a TTGraphObjectBase.
Definition: TTGraphOutlet.h:30
No Error.
Definition: TTBase.h:343
Jamoma Asynchronous Object Graph Layer.