23 typedef struct extra {
28 #define EXTRA ((t_extra*)x->extra)
32 void WrapTTApplicationClass(WrappedClassPtr c);
33 void WrappedApplicationClass_new(
TTPtr self,
long argc, t_atom *argv);
34 void WrappedApplicationClass_free(
TTPtr self);
36 void modular_assist(
TTPtr self,
void *b,
long msg,
long arg,
char *dst);
38 void modular_protocol_setup(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv);
39 void modular_protocol_scan(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv);
41 void modular_namespace_read(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv);
42 void modular_namespace_doread(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv);
44 void modular_namespace_write(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv);
45 void modular_namespace_dowrite(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv);
47 extern "C" void JAMOMA_EXPORT_MAXOBJ setup_j0x2emodular(
void)
49 ModularSpec *spec =
new ModularSpec;
50 spec->_wrap = &WrapTTApplicationClass;
51 spec->_new = &WrappedApplicationClass_new;
53 spec->_free = &WrappedApplicationClass_free;
59 void WrapTTApplicationClass(WrappedClassPtr c)
61 eclass_addmethod(c->pdClass, (method)modular_assist,
"assist", A_CANT, 0L);
63 eclass_addmethod(c->pdClass, (method)modular_protocol_setup,
"protocol/setup", A_GIMME, 0);
65 eclass_addmethod(c->pdClass, (method)modular_protocol_scan,
"protocol/scan", A_GIMME, 0);
67 eclass_addmethod(c->pdClass, (method)modular_namespace_read,
"namespace/read", A_GIMME, 0);
69 eclass_addmethod(c->pdClass, (method)modular_namespace_write,
"namespace/write", A_GIMME, 0);
72 void WrappedApplicationClass_new(
TTPtr self,
long argc, t_atom *argv)
79 long attrstart = attr_args_offset(argc, argv);
89 protocolName =
TTSymbol(atom_getsym(argv)->s_name);
93 else if (attrstart == 2) {
96 applicationName =
TTSymbol(atom_getsym(argv)->s_name);
107 protocolName =
TTSymbol(atom_getsym(argv+1)->s_name);
110 if (protocolName ==
TTSymbol(
"Minuit"))
117 if (protocolName != kTTSymEmpty) {
122 if (!protocol.
valid()) {
127 pd_error((t_object*)x,
"Can't instantiate protocole %s. Reason : %s", protocolName.
c_str(),e.getReason());
135 protocol.
send(
"ApplicationRegister", applicationName, out);
138 protocol.
send(
"Run");
143 EXTRA->protocolName = protocolName;
146 anXmlHandler =
TTObject(kTTSym_XmlHandler);
150 if (attrstart && argv) attr_args_process(x, argc, argv);
153 void WrappedApplicationClass_free(
TTPtr self)
166 TTObject empty, anXmlHandler = o[0];
167 anXmlHandler.
set(kTTSym_object, empty);
170 if (EXTRA->protocolName != kTTSymEmpty) {
174 protocol.
send(
"ApplicationUnregister", applicationName, out);
189 void modular_assist(
TTPtr self,
void *b,
long msg,
long arg,
char *dst)
192 strcpy(dst,
"input");
196 strcpy(dst,
"dumpout");
202 void modular_protocol_setup(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv)
205 TTSymbol applicationName, parameterName;
207 TTValue v, out, parameterValue;
213 if (aProtocol.
valid()) {
220 aProtocol.
send(
"Stop");
224 if (aProtocol.
send(
"ApplicationSelect", applicationName, out))
225 pd_error((t_object*)x,
"%s is not registered to the %s protocol", applicationName.
c_str(), EXTRA->protocolName.c_str());
228 parameterName =
TTSymbol(atom_getsym(argv)->s_name);
230 if (aProtocol.
set(parameterName, parameterValue))
231 pd_error((t_object*)x,
"%s is not a parameter of %s protocol", parameterName.
c_str(), EXTRA->protocolName.c_str());
234 aProtocol.
send(
"Run");
241 if (aProtocol.
send(
"ApplicationSelect", applicationName, out))
242 pd_error((t_object*)x,
"%s is not registered to the %s protocol", applicationName.
c_str(), EXTRA->protocolName.c_str());
244 aProtocol.
get(
"parameterNames", out);
245 for (TTElementIter it = out.begin() ; it != out.end() ; it++) {
248 aProtocol.
get(parameterName, parameterValue);
253 outlet_anything(x->dumpOut, gensym(
"protocol/setup"), ac, av);
258 pd_error((t_object*)x,
"doesn't handle any application");
262 void modular_protocol_scan(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv)
272 if (aProtocol.
valid()) {
276 aProtocol.
send(
"Scan", args, out);
282 outlet_anything((t_outlet*)x->dumpOut, gensym(
"protocol/scan"), ac, av);
286 void modular_namespace_read(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv)
288 modular_namespace_doread((t_object*)
self, msg, argc, argv);
292 void modular_namespace_doread(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv)
312 tterr = anXmlHandler.
send(kTTSym_Read, v, none);
316 outlet_anything(x->dumpOut, _sym_read, argc, argv);
318 outlet_anything(x->dumpOut, _sym_error, 0, NULL);
323 void modular_namespace_write(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv)
325 modular_namespace_dowrite((t_object*)
self, msg, argc, argv);
329 void modular_namespace_dowrite(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv)
332 char filename[MAX_FILENAME_CHARS];
341 snprintf(filename, MAX_FILENAME_CHARS,
"namespace.xml");
351 tterr = anXmlHandler.
send(kTTSym_Write, v, none);
355 object_obex_dumpout(
self, _sym_write, argc, argv);
357 object_obex_dumpout(
self, _sym_error, 0, NULL);
TTErr sendMessage(const TTSymbol name)
TODO: Document this function.
TTErr send(const TTSymbol aName)
Send a message to this object with no arguments.
TTErr lookup(const TTSymbol key, TTValue &value)
Find the value for the given key.
Create and use Jamoma object instances.
void * extra
used to keep very specific things
TTHashPtr internals
An hash table to store any internal TTObjectBases (like TTData, TTViewer, ...)
void prepend(const TTValue &aValueToPrepend)
Insert another TTValue before the first element.
void append(const T &anElementValueToAppend)
Insert a single TTElement at the end.
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.
A TTBlue exception is thown with this object.
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...
#define accessApplication(applicationName)
Access to an application by name.
TTErr append(const TTSymbol key, const TTValue &value)
Insert an item into the hash table.
#define accessApplicationLocal
Access to local application.
TTObject wrappedObject
The instance of the Jamoma object we are wrapping.
Individual items found in a TTValue.
const char * c_str() const
Return a pointer to the internal string as a C-string.
Wraps Jamoma Core classes as objects for PureData.
Data Structure for this object.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
TTBoolean valid() const
Determine if the object contained by this TTObject is truly ready for use.
WrappedModularInstance * WrappedModularInstancePtr
Pointer to a wrapped instance of our object.
#define accessProtocol(protocolName)
Access to a protocol by name.
[doxygenAppendixC_copyExample]
TTErr wrapTTModularClassAsPdClass(TTSymbol &ttblueClassName, const char *pdClassName, WrappedClassPtr *c, ModularSpec *specificities)
Wrap a Jamoma class as a Pd class.