22 typedef struct extra {
27 #define EXTRA ((t_extra*)x->extra)
31 void WrapTTApplicationClass(WrappedClassPtr c);
32 void WrappedApplicationClass_new(
TTPtr self,
long argc, t_atom *argv);
33 void WrappedApplicationClass_free(
TTPtr self);
35 void modular_assist(
TTPtr self,
void *b,
long msg,
long arg,
char *dst);
37 void modular_protocol_setup(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv);
38 void modular_protocol_scan(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv);
40 void modular_namespace_read(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv);
41 void modular_namespace_doread(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv);
43 void modular_namespace_write(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv);
44 void modular_namespace_dowrite(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv);
48 ModularSpec *spec =
new ModularSpec;
49 spec->_wrap = &WrapTTApplicationClass;
50 spec->_new = &WrappedApplicationClass_new;
52 spec->_free = &WrappedApplicationClass_free;
57 void WrapTTApplicationClass(WrappedClassPtr c)
59 class_addmethod(c->maxClass, (method)modular_assist,
"assist", A_CANT, 0L);
61 class_addmethod(c->maxClass, (method)modular_protocol_setup,
"protocol/setup", A_GIMME, 0);
63 class_addmethod(c->maxClass, (method)modular_protocol_scan,
"protocol/scan", A_GIMME, 0);
65 class_addmethod(c->maxClass, (method)modular_namespace_read,
"namespace/read", A_GIMME, 0);
67 class_addmethod(c->maxClass, (method)modular_namespace_write,
"namespace/write", A_GIMME, 0);
70 void WrappedApplicationClass_new(
TTPtr self,
long argc, t_atom *argv)
77 long attrstart = attr_args_offset(argc, argv);
87 protocolName =
TTSymbol(atom_getsym(argv)->s_name);
91 else if (attrstart == 2) {
94 applicationName =
TTSymbol(atom_getsym(argv)->s_name);
105 protocolName =
TTSymbol(atom_getsym(argv+1)->s_name);
108 if (protocolName ==
TTSymbol(
"Minuit"))
115 if (protocolName != kTTSymEmpty) {
120 if (!protocol.
valid()) {
123 object_error((t_object*)x,
"the %s protocol is not available", protocolName.
c_str());
129 protocol.
send(
"ApplicationRegister", applicationName, out);
132 protocol.
send(
"Run");
137 EXTRA->protocolName = protocolName;
140 anXmlHandler =
TTObject(kTTSym_XmlHandler);
144 if (attrstart && argv) attr_args_process(x, argc, argv);
147 void WrappedApplicationClass_free(
TTPtr self)
160 TTObject empty, anXmlHandler = o[0];
161 anXmlHandler.
set(kTTSym_object, empty);
164 if (EXTRA->protocolName != kTTSymEmpty) {
168 protocol.
send(
"ApplicationUnregister", applicationName, out);
183 void modular_assist(
TTPtr self,
void *b,
long msg,
long arg,
char *dst)
186 strcpy(dst,
"input");
190 strcpy(dst,
"dumpout");
196 void modular_protocol_setup(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv)
199 TTSymbol applicationName, parameterName;
201 TTValue v, out, parameterValue;
207 if (aProtocol.
valid()) {
214 aProtocol.
send(
"Stop");
218 if (aProtocol.
send(
"ApplicationSelect", applicationName, out))
219 object_error((t_object*)x,
"%s is not registered to the %s protocol", applicationName.
c_str(), EXTRA->protocolName.c_str());
222 parameterName =
TTSymbol(atom_getsym(argv)->s_name);
224 if (aProtocol.
set(parameterName, parameterValue))
225 object_error((t_object*)x,
"%s is not a parameter of %s protocol", parameterName.
c_str(), EXTRA->protocolName.c_str());
228 aProtocol.
send(
"Run");
235 if (aProtocol.
send(
"ApplicationSelect", applicationName, out))
236 object_error((t_object*)x,
"%s is not registered to the %s protocol", applicationName.
c_str(), EXTRA->protocolName.c_str());
238 aProtocol.
get(
"parameterNames", out);
239 for (TTElementIter it = out.begin() ; it != out.end() ; it++) {
242 aProtocol.
get(parameterName, parameterValue);
247 object_obex_dumpout(
self, gensym(
"protocol/setup"), ac, av);
252 object_error((t_object*)x,
"doesn't handle any application");
256 void modular_protocol_scan(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv)
266 if (aProtocol.
valid()) {
270 aProtocol.
send(
"Scan", args, out);
276 object_obex_dumpout(
self, gensym(
"protocol/scan"), ac, av);
280 void modular_namespace_read(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv)
282 defer(
self, (method)modular_namespace_doread, msg, argc, argv);
285 void modular_namespace_doread(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv)
305 tterr = anXmlHandler.
send(kTTSym_Read, v, none);
309 object_obex_dumpout(
self, _sym_read, argc, argv);
311 object_obex_dumpout(
self, _sym_error, 0, NULL);
316 void modular_namespace_write(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv)
318 defer(
self, (method)modular_namespace_dowrite, msg, argc, argv);
321 void modular_namespace_dowrite(
TTPtr self, t_symbol *msg,
long argc, t_atom *argv)
324 char filename[MAX_FILENAME_CHARS];
333 snprintf(filename, MAX_FILENAME_CHARS,
"namespace.xml");
343 tterr = anXmlHandler.
send(kTTSym_Write, v, none);
347 object_obex_dumpout(
self, _sym_write, argc, argv);
349 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 wrapTTModularClassAsMaxClass(TTSymbol &ttblueClassName, const char *maxClassName, WrappedClassPtr *c, ModularSpec *specificities)
Wrap a Jamoma class as a Max class.
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.
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.
int C74_EXPORT main(void)
Set up this class as a Max external the first time an object of this kind is instantiated.
Data Structure for this object.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Wraps Jamoma Core classes as objects for Max/MSP.
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]