Jamoma API  0.6.0.a19
TTGraphInlet.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_INLET_H__
18 #define __TTGRAPH_INLET_H__
19 
20 #include "TTGraph.h"
21 //#include "TTGraphObjectBase.h"
22 #include "TTGraphSource.h"
23 #include "TTGraphDescription.h"
24 
25 /******************************************************************************************/
26 
27 /** This object represents a single 'inlet' to a #TTGraphObjectBase.
28  #TTGraphObjectBase maintains a vector of these inlets.
29 */
30 class TTGRAPH_EXPORT TTGraphInlet {
31 
32 protected:
33 
34  TTGraphSourceVector mSourceObjects; ///< A vector of object pointers from which we pull our source samples using the ::getAudioOutput() method.
35 
36 public:
37 
38  /** Object constructor.
39  */
41  {
42  ;
43  }
44 
45  /** Object destructor.
46  */
48  {
49  ;
50  }
51 
52 
53  TTGraphInlet(const TTGraphInlet& original)
54  {
55  mSourceObjects = original.mSourceObjects;
56  }
57 
58  // The copy assignment constructor doesn't appear to be involved, at least with resizes, on the Mac...
59  TTGraphInlet& operator=(const TTGraphInlet& source)
60  {
61  mSourceObjects = source.mSourceObjects;
62  return *this;
63  }
64 
65 
66  // Graph Methods
67 
68  // reset
69  void reset()
70  {
71  mSourceObjects.clear();
72  }
73 
74 
75  TTErr connect(TTGraphObjectBasePtr anObject, TTUInt16 fromOutletNumber)
76  {
77  TTUInt16 size = mSourceObjects.size();
78 
79  // make sure the connection doesn't already exist
80  for (TTGraphSourceIter source = mSourceObjects.begin(); source != mSourceObjects.end(); source++) {
81  if (source->match(anObject, fromOutletNumber))
82  return kTTErrNone;
83  }
84 
85  // create the connection
86  mSourceObjects.resize(size+1);
87  mSourceObjects[size].connect(anObject, fromOutletNumber);
88  mSourceObjects[size].setOwner(this);
89  return kTTErrNone;
90  }
91 
92 
93  TTErr drop(TTGraphObjectBasePtr anObject, TTUInt16 fromOutletNumber)
94  {
95  for (TTGraphSourceIter source = mSourceObjects.begin(); source != mSourceObjects.end(); source++) {
96  if (source->match(anObject, fromOutletNumber)) {
97  drop(*source);
98  break;
99  }
100  }
101  return kTTErrNone;
102  }
103 
104 
105  void drop(TTGraphSource& aSource)
106  {
107  TTGraphSourceIter iter = find(mSourceObjects.begin(), mSourceObjects.end(), aSource);
108 
109  if (iter != mSourceObjects.end())
110  mSourceObjects.erase(iter);
111  }
112 
113 
114  void prepareDescriptions()
115  {
116  for (TTGraphSourceIter source = mSourceObjects.begin(); source != mSourceObjects.end(); source++)
117  source->prepareDescription();
118  }
119 
120  void getDescriptions(TTGraphDescriptionVector& descs);
121 
122 };
123 
125 typedef std::vector<TTGraphInlet> TTGraphInletVector;
126 typedef TTGraphInletVector::iterator TTGraphInletIter;
127 
128 
129 #endif // __TTGRAPH_INLET_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.
Jamoma Asynchronous Object Graph Layer.
~TTGraphInlet()
Object destructor.
Definition: TTGraphInlet.h:47
TTGraphSourceVector mSourceObjects
A vector of object pointers from which we pull our source samples using the ::getAudioOutput() method...
Definition: TTGraphInlet.h:34
TTGraphInlet()
Object constructor.
Definition: TTGraphInlet.h:40
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 'inlet' to a TTGraphObjectBase.
Definition: TTGraphInlet.h:30
No Error.
Definition: TTBase.h:343
Jamoma Asynchronous Object Graph Layer.