Jamoma API  0.6.0.a19
Minuit.h
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  Copyright:
18  LaBRI (http://www.labri.fr) - BlueYeti (http://www.blueyeti.fr) - GMEA (http://www.gmea.net)
19 
20  Author(s): Laurent Garnier, Theo Delahogue
21  Last modification: 16/08/2011
22 
23  Adviser(s):
24  Myriam Desainte-Catherine (myriam.desainte-catherine@labri.fr)
25 
26  This software is a computer program whose purpose is to propose
27  a library for interactive scores edition and execution.
28 
29  This software is governed by the CeCILL-C license under French law and
30  abiding by the rules of distribution of free software. You can use,
31  modify and/ or redistribute the software under the terms of the CeCILL-C
32  license as circulated by CEA, CNRS and INRIA at the following URL
33  "http://www.cecill.info".
34 
35  As a counterpart to the access to the source code and rights to copy,
36  modify and redistribute granted by the license, users are provided only
37  with a limited warranty and the software's author, the holder of the
38  economic rights, and the successive licensors have only limited
39  liability.
40 
41  In this respect, the user's attention is drawn to the risks associated
42  with loading, using, modifying and/or developing or reproducing the
43  software by the user in light of its specific status of free software,
44  that may mean that it is complicated to manipulate, and that also
45  therefore means that it is reserved for developers and experienced
46  professionals having in-depth computer knowledge. Users are therefore
47  encouraged to load and test the software's suitability as regards their
48  requirements in conditions enabling the security of their systems and/or
49  data to be ensured and, more generally, to use and operate it in the
50  same conditions as regards security.
51 
52  The fact that you are presently reading this means that you have had
53  knowledge of the CeCILL-C license and that you accept its terms.
54  */
55 
56 
57 #ifndef __MINUIT_H__
58 #define __MINUIT_H__
59 
60 #include "TTProtocol.h"
61 #include "MinuitInclude.h"
62 #include "MinuitAnswerManager.h"
63 #include "MinuitSenderManager.h"
64 
65 class MinuitAnswerManager;
66 typedef MinuitAnswerManager* MinuitAnswerManagerPtr;
67 
68 class MinuitSenderManager;
69 typedef MinuitSenderManager* MinuitSenderManagerPtr;
70 
71 class Minuit : public TTProtocol {
72 
73  TTCLASS_SETUP(Minuit)
74 
75 private:
76 
77  TT_PROTOCOL_PARAMETER(Ip); ///< PROTOCOL PARAMETER : each registered application have to setup its ip
78  TT_PROTOCOL_PARAMETER(Port); ///< PROTOCOL PARAMETER : each registered application have to setup its port
79 
80  TTObject mOscReceive;
81 
82  MinuitAnswerManagerPtr mAnswerManager;
83  MinuitSenderManagerPtr mSenderManager;
84 
85  TTErr sendMessage(TTSymbol applicationName, TTSymbol header, TTValue& message);
86  TTErr receivedMessage(const TTValue& message, TTValue& outputValue);
87 
88 
89  /** Scan to find remote applications and add them to the application manager
90  * \param inputValue : anything needed for scanning
91  * \param outputValue : all remote application name
92  * \return errorcode : return a kTTErrGeneric if the protocol fails to start or if it was running already
93  */
94  TTErr Scan(const TTValue& inputValue, TTValue& outputValue);
95 
96  /*!
97  * Run reception thread mechanism for the local application only
98  * \param inputValue : nothing to run all registered applications or a #TTSymbol application name
99  * \param outputValue : when the running failed because of a port connection failure : the port number
100  * \return errorcode : return a kTTErrGeneric if the protocol fails to start or if it was running already
101  */
102  TTErr Run(const TTValue& inputValue, TTValue& outputValue);
103 
104  /*!
105  * Stop the reception thread mechanism for the local application only
106  * \param inputValue : nothing to stop all registered applications or a #TTSymbol application name
107  * \param outputValue : any informations relative to a failure when stopping the protocol
108  * \return errorcode : return a kTTErrGeneric if the protocol fails to stop or if it was already stopped
109  */
110  TTErr Stop(const TTValue& inputValue, TTValue& outputValue);
111 
112  /**************************************************************************************************************************
113  *
114  * SEND REQUEST METHODS
115  *
116  **************************************************************************************************************************/
117 
118  /*!
119  * Send a discover request to an application to get a part of the namespace at the given address
120  *
121  * \param to : the application where to discover
122  * \param address : the address to discover
123  * \param returnedType : the type of the node at the address (default is none which means no type)
124  * \param returnedChildren : all names of nodes below the address
125  * \param returnedAttributes : all attributes the node at the address
126  * \param tryCount : number of try for this request
127  * \return errorcode : kTTErrNone means the answer has been received, kTTErrValueNotFound means something is bad in the request
128  else it returns kTTErrGeneric if no answer or timeout
129  */
130  TTErr SendDiscoverRequest(TTSymbol to, TTAddress address,
131  TTSymbol& returnedType,
132  TTValue& returnedChildren,
133  TTValue& returnedAttributes,
134  TTUInt8 tryCount=0);
135 
136  /*!
137  * Send a discover all request to an application to fill all the directory under this address
138  *
139  * \param to : the application where to discover
140  * \param address : the address to discover
141  * \param node : the node for this address
142  * \param tryCount : number of try for this request
143  * \return errorcode : kTTErrNone means the answer has been received, kTTErrValueNotFound means something is bad in the request
144  else it returns kTTErrGeneric if no answer or timeout
145  */
146  TTErr SendDiscoverAllRequest(TTSymbol to, TTAddress address,
147  TTNodePtr node,
148  TTUInt8 tryCount=0);
149 
150  /*!
151  * Send a get request to an application to get a value at the given address
152  *
153  * \param to : the application where to get
154  * \param address : the address to get
155  * \param returnedValue : the value which is going to be filled
156  * \param tryCount : number of try for this request
157  * \return errorcode : kTTErrNone means the answer has been received, kTTErrValueNotFound means something is bad in the request
158  else it returns kTTErrGeneric if no answer or timeout
159  */
160  TTErr SendGetRequest(TTSymbol to, TTAddress address,
161  TTValue& returnedValue,
162  TTUInt8 tryCount=0);
163 
164  /*!
165  * Send a set request to set a value of a specific application
166  *
167  * \param to : the application where to set
168  * \param address : the address to set
169  * \param value : anything to send
170  * \param tryCount : number of try for this request
171  * \return errorcode : kTTErrNone means the answer has been received, kTTErrValueNotFound means something is bad in the request
172  */
173  TTErr SendSetRequest(TTSymbol to, TTAddress address,
174  TTValue& value,
175  TTUInt8 tryCount=0);
176 
177  /*!
178  * Send a listen request to a specific application
179  *
180  * \param to : the application where to listen
181  * \param address : the address to listen
182  * \param attribute : the attribute to listen
183  * \param enable : enable/disable the listening
184  * \param tryCount : number of try for this request
185  * \return errorcode : kTTErrNone means the answer has been received, kTTErrValueNotFound means something is bad in the request
186  */
187  TTErr SendListenRequest(TTSymbol to, TTAddress address,
188  TTBoolean enable,
189  TTUInt8 tryCount=0);
190 
191 
192  /**************************************************************************************************************************
193  *
194  * SEND ANSWER METHODS
195  *
196  **************************************************************************************************************************/
197 
198  /*!
199  * Send a disover answer to a application which ask for.
200  *
201  * \param to : the application where to send answer
202  * \param address : the address where comes from the description
203  * \param returnedType : the type of the node at the address (default is none which means no type)
204  * \param returnedChildren : all names of nodes below the address
205  * \param returnedAttributes : all attributes the node at the address
206  */
207  TTErr SendDiscoverAnswer(TTSymbol to, TTAddress address,
208  TTSymbol& returnedType,
209  TTValue& returnedChildren,
210  TTValue& returnedAttributes,
211  TTErr err=kTTErrNone);
212 
213  /*!
214  * Send a discover answer to a application which ask for.
215  *
216  * \param to : the application where to send answer
217  * \param address : the address where comes from the description
218  * \param node : the node for this address
219  */
220  TTErr SendDiscoverAllAnswer(TTSymbol to, TTAddress address,
221  TTNodePtr node,
222  TTErr err=kTTErrNone);
223 
224  /*!
225  * Send a get answer to a application which ask for.
226  *
227  * \param to : the application where to send answer
228  * \param address : the address where comes from the value
229  * \param returnedValue : the value of the attribute at the address
230  */
231  TTErr SendGetAnswer(TTSymbol to, TTAddress address,
232  const TTValue& returnedValue,
233  TTErr err=kTTErrNone);
234 
235  /*!
236  * Send a listen answer to a application which ask for.
237  *
238  * \param to : the application where to send answer
239  * \param address : the address where comes from the value
240  * \param returnedValue : the value of the attribute at the address
241  */
242  TTErr SendListenAnswer(TTSymbol to, TTAddress address,
243  const TTValue& returnedValue,
244  TTErr err=kTTErrNone);
245 
246 };
247 typedef Minuit* MinuitPtr;
248 
249 #endif // __MINUIT_H__
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
Definition: TTBase.h:167
We build a directory of TTNodes, and you can request a pointer for any TTNode, or add an observer to ...
Definition: TTNode.h:59
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
TTProtocol is the base class for all protocol protocol.
Definition: TTProtocol.h:60
#define TTCLASS_SETUP(className)
TODO Doxygen: need more comments here.
Definition: TTFoundation.h:54
#define TT_PROTOCOL_PARAMETER(name)
Declares specific accessors methods to manage the parameter value in order to have one value per regi...
Definition: TTProtocol.h:43
A Protocol interface.
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
A OSC send object manager.
A Protocol interface.
No Error.
Definition: TTBase.h:343
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
unsigned char TTUInt8
8 bit unsigned integer (char)
Definition: TTBase.h:174