Jamoma API  0.6.0.a19
PureData/source/j.cue/j.cue.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup implementationPdExternals
4  *
5  * @brief j.cue - store and recall the state of several models
6  *
7  * @details
8  *
9  * @authors Théo de la Hogue, Trond Lossius, Antoine Villeret
10  *
11  * @copyright © 2010 by Théo de la Hogue @n
12  * Copyright © 2015, Antoine Villeret@n
13  * This code is licensed under the terms of the "New BSD License" @n
14  * http://creativecommons.org/licenses/BSD/
15  */
16 
17 
19 
20 // This is used to store extra data
21 typedef struct extra {
22  TTObject *toEdit; // the object to edit (a cue or all the cuelist)
23  TTSymbol cueName; // the name of the edited cue
24  TTString *text; // the text of the editor to read after edclose
25  t_object* textEditor; // the text editor window
26 } t_extra;
27 #define EXTRA ((t_extra*)x->extra)
28 
29 #define line_out 0
30 #define dump_out 1
31 
32 // Definitions
33 void WrapTTCueManagerClass(WrappedClassPtr c);
34 void WrappedCueManagerClass_new(TTPtr self, long argc, t_atom *argv);
35 void WrappedCueManageClass_free(TTPtr self);
36 
37 void cue_assist(TTPtr self, void *b, long msg, long arg, char *dst);
38 
39 void cue_return_value(TTPtr self, t_symbol *msg, long argc, t_atom *argv);
40 void cue_return_names(TTPtr self, t_symbol *msg, long argc, t_atom *argv);
41 
42 void cue_get(TTPtr self, t_symbol *msg, long argc, t_atom *argv);
43 void cue_set(TTPtr self, t_symbol *msg, long argc, t_atom *argv);
44 
45 void cue_read(TTPtr self, t_symbol *msg, long argc, t_atom *argv);
46 void cue_doread(TTPtr self, t_symbol *msg, long argc, t_atom *argv);
47 void cue_read_again(TTPtr self);
48 void cue_doread_again(TTPtr self);
49 
50 void cue_write(TTPtr self, t_symbol *msg, long argc, t_atom *argv);
51 void cue_dowrite(TTPtr self, t_symbol *msg, long argc, t_atom *argv);
52 void cue_write_again(TTPtr self);
53 void cue_dowrite_again(TTPtr self);
54 
55 void cue_dorecall(TTPtr self, t_symbol *msg, long argc, t_atom *argv);
56 
57 void cue_edit(TTPtr self, t_symbol *msg, long argc, t_atom *argv);
58 void cue_edclose(TTPtr self, char **text, long size);
59 void cue_doedit(TTPtr self);
60 
61 void cue_subscribe(TTPtr self);
62 
63 void cue_return_model_address(TTPtr self, t_symbol *msg, long argc, t_atom *argv);
64 
65 t_max_err cue_get_relative(TTPtr self, TTPtr attr, long *ac, t_atom **av);
66 t_max_err cue_set_relative(TTPtr self, TTPtr attr, long ac, t_atom *av);
67 
68 extern "C" void JAMOMA_EXPORT_MAXOBJ setup_j0x2ecue(void)
69 {
70  ModularSpec *spec = new ModularSpec;
71  spec->_wrap = &WrapTTCueManagerClass;
72  spec->_new = &WrappedCueManagerClass_new;
73  spec->_free = &WrappedCueManageClass_free;
74  spec->_any = NULL;
75 
76  return (void)wrapTTModularClassAsPdClass(kTTSym_CueManager, "j.cue", NULL, spec);
77 }
78 
79 void WrapTTCueManagerClass(WrappedClassPtr c)
80 {
81  eclass_addmethod(c->pdClass, (method)cue_assist, "assist", A_CANT, 0L);
82 
83  eclass_addmethod(c->pdClass, (method)cue_subscribe, "loadbang", A_NULL, 0L);
84 
85  eclass_addmethod(c->pdClass, (method)cue_return_model_address, "return_model_address", A_CANT, 0);
86 
87  eclass_addmethod(c->pdClass, (method)cue_return_value, "return_value", A_CANT, 0);
88 
89  eclass_addmethod(c->pdClass, (method)cue_return_names, "return_names", A_CANT, 0);
90 
91  eclass_addmethod(c->pdClass, (method)cue_read, "cue_read", A_CANT, 0);
92  eclass_addmethod(c->pdClass, (method)cue_write, "cue_write", A_CANT, 0);
93 
94  eclass_addmethod(c->pdClass, (method)cue_edit, "dblclick", A_CANT, 0);
95  eclass_addmethod(c->pdClass, (method)cue_edclose, "edclose", A_CANT, 0);
96 
97  eclass_addmethod(c->pdClass, (method)cue_get, "get", A_GIMME, 0);
98  eclass_addmethod(c->pdClass, (method)cue_set, "set", A_GIMME, 0);
99 
100  eclass_addmethod(c->pdClass, (method)cue_read, "read", A_GIMME, 0);
101  eclass_addmethod(c->pdClass, (method)cue_write, "write", A_GIMME, 0);
102  eclass_addmethod(c->pdClass, (method)cue_edit, "edit", A_GIMME, 0);
103 
104  eclass_addmethod(c->pdClass, (method)cue_read_again, "read/again", A_NULL, 0);
105  eclass_addmethod(c->pdClass, (method)cue_write_again, "write/again", A_NULL, 0);
106 
107  CLASS_ATTR_LONG(c->pdClass, "relative", 0, WrappedModularInstance, index); // use index member to store relative
108  CLASS_ATTR_ACCESSORS(c->pdClass, "relative", cue_get_relative, cue_set_relative);
109  CLASS_ATTR_STYLE(c->pdClass, "relative", 0, "onoff");
110 }
111 
112 void WrappedCueManagerClass_new(TTPtr self, long argc, t_atom *argv)
113 {
115  t_symbol* name;
116  TTValue v, args;
117  TTObject aTextHandler;
118  long attrstart = attr_args_offset(argc, argv); // support normal arguments
119 
120  // create the cue manager
121  jamoma_cueManager_create((t_object*)x, x->wrappedObject);
122 
123  // read first argument to know if the cue binds a namespace
124  if (attrstart && argv) {
125 
126  if (atom_gettype(argv) == A_SYM) {
127 
128  name = atom_getsym(argv);
129  x->wrappedObject.set(kTTSym_namespace, TTSymbol(name->s_name));
130  }
131  else
132  pd_error((t_object*)x, "argument not expected");
133  }
134 
135  // Make two outlets
136  x->outlets = (TTHandle)sysmem_newptr(sizeof(TTPtr) * 1);
137  x->outlets[line_out] = outlet_new((t_object*)x, NULL); // anything outlet to output data
138 
139  // Prepare Internals hash to store TextHandler object
140  x->internals = new TTHash();
141 
142  // create internal TTTextHandler
143  aTextHandler = TTObject(kTTSym_TextHandler);
144  x->internals->append(kTTSym_TextHandler, aTextHandler);
145 
146  // Prepare extra data
147  x->extra = (t_extra*)malloc(sizeof(t_extra));
148  EXTRA->toEdit = new TTObject();
149  *EXTRA->toEdit = x->wrappedObject;
150  EXTRA->cueName = kTTSymEmpty;
151  EXTRA->text = NULL;
152  EXTRA->textEditor = NULL;
153 
154  // handle attribute args
155  attr_args_process(x, argc, argv);
156 }
157 
158 void WrappedCueManageClass_free(TTPtr self)
159 {
161 
162  delete EXTRA->toEdit;
163 
164  // the texthanler have to forget the cue manager object
165  TTValue o;
166  x->internals->lookup(kTTSym_TextHandler, o);
167  TTObject empty, aTextHandler = o[0];
168  aTextHandler.set(kTTSym_object, empty);
169 
170  free(EXTRA);
171 }
172 
173 void cue_subscribe(TTPtr self)
174 {
176  TTValue v;
177  TTAddress contextAddress = kTTAdrsEmpty;
178  TTAddress absoluteAddress, returnedAddress;
179  TTNodePtr returnedNode;
180  TTNodePtr returnedContextNode;
181  TTObject anObject, empty;
182 
183  jamoma_patcher_get_info(((t_eobj*)x)->o_canvas, &x->patcherPtr, x->patcherContext, x->patcherClass, x->patcherName);
184 
185  if (!jamoma_subscriber_create((t_eobj*)x, empty, kTTAdrsEmpty, x->subscriberObject, returnedAddress, &returnedNode, &returnedContextNode)) {
186 
187  // get the context address to make
188  // a receiver on the contextAddress/model:address attribute
189  x->subscriberObject.get("contextAddress", v);
190  contextAddress = v[0];
191  }
192 
193  post("j.cue : contextAddress : %s",contextAddress.c_str());
194 
195  // bind on the model:address attribute
196  if (contextAddress != kTTAdrsEmpty) {
197 
198  absoluteAddress = contextAddress.appendAddress(x->address);
199  x->wrappedObject.set(kTTSym_address, x->address);
200 
201  makeInternals_receiver(x, contextAddress, TTSymbol("/model:address"), gensym("return_model_address"), anObject, YES); // YES : we want to deferlow this method
202  }
203 
204  // while the context node is not registered : try to binds again :(
205  // (to -- this is not a good way todo. For binding we should make a subscription
206  // to a notification mechanism and each time an TTObjet subscribes to the namespace
207  // using jamoma_subscriber_create we notify all the externals which have used
208  // jamoma_subscriber_create with NULL object to bind)
209  else {
210 
211  // release the subscriber
212  x->subscriberObject = TTObject();
213 
214  // The following must be deferred because we have to interrogate our box,
215  // and our box is not yet valid until we have finished instantiating the object.
216  // Trying to use a loadbang method instead is also not fully successful (as of Max 5.0.6)
217  // defer_low((t_object*)x, (method)cue_subscribe, NULL, 0, 0);
218  cue_subscribe(x); // actually in Pd this could cause an infinite loop...
219  }
220 }
221 
222 void cue_return_model_address(TTPtr self, t_symbol *msg, long argc, t_atom *argv)
223 {
225  TTAddress absoluteAddress;
226 
227  if (argc && argv) {
228 
229  // set address attribute of the wrapped Receiver object
230  absoluteAddress = TTAddress(atom_getsym(argv)->s_name).appendAddress(x->address);
231  x->wrappedObject.set(kTTSym_address, absoluteAddress);
232  }
233 }
234 
235 // Method for Assistance Messages
236 void cue_assist(TTPtr self, void *b, long msg, long arg, char *dst)
237 {
238  if (msg==1) // Inlets
239  strcpy(dst, "");
240  else { // Outlets
241  switch(arg) {
242  case line_out:
243  strcpy(dst, "cue output");
244  break;
245  case dump_out:
246  strcpy(dst, "dumpout");
247  break;
248  }
249  }
250 }
251 
252 void cue_return_value(TTPtr self, t_symbol *msg, long argc, t_atom *argv)
253 {
255 
256  // avoid blank before line
257  if (msg == _sym_nothing)
258  outlet_anything((t_outlet*)x->outlets[line_out], _sym_nothing, argc, argv);
259  else
260  outlet_anything((t_outlet*)x->outlets[line_out], msg, argc, argv);
261 }
262 
263 void cue_return_names(TTPtr self, t_symbol *msg, long argc, t_atom *argv)
264 {
266  outlet_anything((t_outlet*)x->outlets[dump_out], gensym("names"), argc, argv);
267 }
268 
269 void cue_get(TTPtr self, t_symbol *msg, long argc, t_atom *argv)
270 {
272  TTHashPtr allCues;
273  TTValue v;
274  TTSymbol name, attribute;
275  TTObject cue;
276  long ac = 0;
277  t_atom *av = NULL;
278 
279  if (argc == 2) {
280 
281  if (atom_gettype(argv) == A_SYM && atom_gettype(argv+1) == A_SYM) {
282 
283  attribute = TTSymbol((char*)atom_getsym(argv)->s_name);
284  name = TTSymbol((char*)atom_getsym(argv+1)->s_name);
285 
286  // get cue object table
287  x->wrappedObject.get("cues", v);
288  allCues = TTHashPtr((TTPtr)v[0]);
289 
290  if (allCues) {
291 
292  // get cue
293  if (!allCues->lookup(name, v)) {
294 
295  cue = v[0];
296  if (!cue.get(attribute, v)) {
297 
298  v.prepend(name);
299  jamoma_ttvalue_to_Atom(v, &ac, &av);
300 
301  outlet_anything((t_outlet*)x->dumpOut, atom_getsym(argv), ac, av);
302  }
303  else
304  pd_error((t_object*)x, "%s attribute doesn't exist", atom_getsym(argv)->s_name);
305  }
306  else
307  pd_error((t_object*)x, "%s cue doesn't exist", atom_getsym(argv+1)->s_name);
308  }
309  }
310  }
311 }
312 
313 void cue_set(TTPtr self, t_symbol *msg, long argc, t_atom *argv)
314 {
316  TTHashPtr allCues;
317  TTValue v;
318  TTSymbol name, attribute;
319  TTObject cue;
320 
321  if (argc >= 2) {
322 
323  if (atom_gettype(argv) == A_SYM && atom_gettype(argv+1) == A_SYM) {
324 
325  attribute = TTSymbol((char*)atom_getsym(argv)->s_name);
326  name = TTSymbol((char*)atom_getsym(argv+1)->s_name);
327 
328  // get cue object table
329  x->wrappedObject.get("cues", v);
330  allCues = TTHashPtr((TTPtr)v[0]);
331 
332  if (allCues) {
333 
334  // get cue
335  if (!allCues->lookup(name, v)) {
336 
337  cue = v[0];
338 
339  // prepare value to set
340  jamoma_ttvalue_from_Atom(v, _sym_nothing, argc-2, argv+2);
341 
342  if (cue.set(attribute, v))
343  pd_error((t_object*)x, "%s attribute doesn't exist", atom_getsym(argv)->s_name);
344  }
345  else
346  pd_error((t_object*)x, "%s cue doesn't exist", atom_getsym(argv+1)->s_name);
347  }
348  }
349  }
350 }
351 
352 void cue_read(TTPtr self, t_symbol *msg, long argc, t_atom *argv)
353 {
354  // defer(self, (method)cue_doread, msg, argc, argv);
355  cue_doread(self,msg,argc,argv);
356 }
357 
358 void cue_doread(TTPtr self, t_symbol *msg, long argc, t_atom *argv)
359 {
361  TTValue o, v, none;
362  TTSymbol fullpath;
363  TTObject aTextHandler;
364  TTErr tterr;
365 
366  if (x->wrappedObject.valid()) {
367 
368  fullpath = jamoma_file_read((t_object*)x, argc, argv, (t_fourcc)'TEXT');
369  v.append(fullpath);
370 
371  tterr = x->internals->lookup(kTTSym_TextHandler, o);
372 
373  if (!tterr) {
374 
375  aTextHandler = o[0];
376 
377  aTextHandler.set(kTTSym_object, x->wrappedObject);
378 
379 // critical_enter(0);
380  tterr = aTextHandler.send(kTTSym_Read, v, none);
381 // critical_exit(0);
382 
383  if (!tterr)
384  outlet_anything((t_outlet*)x->dumpOut, _sym_read, argc, argv);
385  else
386  outlet_anything((t_outlet*)x->dumpOut, _sym_error, 0, NULL);
387  }
388  }
389 }
390 
391 void cue_read_again(TTPtr self)
392 {
393  cue_doread(self,NULL,0,NULL);
394  // defer(self, (method)cue_doread_again, NULL, 0, NULL);
395 }
396 
397 void cue_doread_again(TTPtr self)
398 {
400  TTValue o, v, none;
401  TTObject aTextHandler;
402  TTErr tterr;
403 
404  if (x->wrappedObject.valid()) {
405 
406  tterr = x->internals->lookup(kTTSym_TextHandler, o);
407 
408  if (!tterr) {
409 
410  aTextHandler = o[0];
411 
412  aTextHandler.set(kTTSym_object, x->wrappedObject);
413 
414 // critical_enter(0);
415  tterr = aTextHandler.send(kTTSym_ReadAgain, v, none);
416 // critical_exit(0);
417 
418  if (!tterr)
419  outlet_anything((t_outlet*)x->dumpOut, _sym_read, 0, NULL);
420  else
421  outlet_anything((t_outlet*)x->dumpOut, _sym_error, 0, NULL);
422  }
423  }
424 }
425 
426 void cue_write(TTPtr self, t_symbol *msg, long argc, t_atom *argv)
427 {
428 // defer(self, (method)cue_dowrite, msg, argc, argv);
429  cue_dowrite(self, msg, argc, argv);
430 }
431 
432 void cue_dowrite(TTPtr self, t_symbol *msg, long argc, t_atom *argv)
433 {
435  char filename[MAX_FILENAME_CHARS];
436  TTSymbol fullpath;
437  TTValue o, v, none;
438  TTObject aTextHandler;
439  TTErr tterr;
440 
441  if (x->wrappedObject.valid()) {
442 
443  // Default TEXT File Name
444  snprintf(filename, MAX_FILENAME_CHARS, "untitled.cues.txt");
445 
446  fullpath = jamoma_file_write((t_object*)x, argc, argv, filename);
447  v.append(fullpath);
448 
449  tterr = x->internals->lookup(kTTSym_TextHandler, o);
450 
451  if (!tterr) {
452  aTextHandler = o[0];
453 
454  aTextHandler.set(kTTSym_object, x->wrappedObject);
455 
456 // critical_enter(0);
457  tterr = aTextHandler.send(kTTSym_Write, v, none);
458 // critical_exit(0);
459 
460  if (!tterr)
461  outlet_anything((t_outlet*) x->dumpOut, _sym_write, argc, argv);
462  else
463  outlet_anything((t_outlet*) x->dumpOut, _sym_error, 0, NULL);
464  }
465  }
466 }
467 
468 void cue_write_again(TTPtr self)
469 {
470 // defer(self, (method)cue_dowrite_again, NULL, 0, NULL);
471  cue_dowrite(self,NULL,0,NULL);
472 }
473 
474 void cue_dowrite_again(TTPtr self)
475 {
477  TTValue o, v, none;
478  TTObject aTextHandler;
479  TTErr tterr;
480 
481  if (x->wrappedObject.valid()) {
482 
483  tterr = x->internals->lookup(kTTSym_TextHandler, o);
484 
485  if (!tterr) {
486 
487  aTextHandler = o[0];
488 
489  aTextHandler.set(kTTSym_object, x->wrappedObject);
490 
491 // critical_enter(0);
492  tterr = aTextHandler.send(kTTSym_WriteAgain, v, none);
493 // critical_exit(0);
494 
495  if (!tterr)
496  outlet_anything((t_outlet*)x->dumpOut, _sym_write, 0, NULL);
497  else
498  outlet_anything((t_outlet*)x->dumpOut, _sym_error, 0, NULL);
499  }
500  }
501 }
502 
503 void cue_dorecall(TTPtr self, t_symbol *msg, long argc, t_atom *argv)
504 {
506  TTValue v, none;
507  TTNodePtr contextNode;
508  TTObject o;
509  TTBoolean initialized;
510 
511  if (argc && argv) {
512  if (atom_gettype(argv) == A_SYM) {
513 
514  x->wrappedObject.send(kTTSym_Recall, TTSymbol(atom_getsym(argv)), none);
515  }
516 
517  // Check Context Node
518  if (x->subscriberObject.valid()) {
519 
520  x->subscriberObject.get("contextNode", v);
521  contextNode = TTNodePtr((TTPtr)v[0]);
522 
523  // If it is a none initialized Container : initialize it
524  o = contextNode->getObject();
525  if (o.valid()) {
526 
527  if (o.name() == kTTSym_Container) {
528 
529  o.get(kTTSym_initialized, v);
530  initialized = v[0];
531 
532  if (!initialized)
533  o.send(kTTSym_Init);
534  }
535  }
536  }
537  }
538 }
539 
540 void cue_edit(TTPtr self, t_symbol *msg, long argc, t_atom *argv)
541 {
543  TTString *buffer;
544  char title[MAX_FILENAME_CHARS];
545  TTObject aTextHandler;
546  TTHashPtr allCues;
547  TTValue v, o, none;
548  TTSymbol name = kTTSymEmpty;
549  t_atom a;
550  TTErr tterr;
551 
552  // choose object to edit : default the cuelist
553  *EXTRA->toEdit = x->wrappedObject;
554  EXTRA->cueName = kTTSymEmpty;
555 
556  if (argc && argv)
557  {
558  if (atom_gettype(argv) == A_LONG)
559  {
560  TTUInt32 index = atom_getlong(argv);
561 
562  // get cues names
563  x->wrappedObject.get("names", v);
564 
565  if (index > 0 && index <= v.size())
566  v.get(index-1, name);
567  else
568  {
569  pd_error((t_object*)x, "%ld doesn't exist", atom_getlong(argv));
570  return;
571  }
572  }
573  else if (atom_gettype(argv) == A_SYM)
574  name = TTSymbol(atom_getsym(argv)->s_name);
575 
576  if (name != kTTSymEmpty)
577  {
578  // get cue object table
579  x->wrappedObject.get("cues", v);
580  allCues = TTHashPtr((TTPtr)v[0]);
581 
582  if (allCues)
583  {
584  // get cue to edit
585  if (!allCues->lookup(name, v))
586  {
587  // edit a cue
588  *EXTRA->toEdit = v[0];
589  EXTRA->cueName = name;
590  }
591  else
592  {
593  pd_error((t_object*)x, "%s doesn't exist", atom_getsym(argv)->s_name);
594  return;
595  }
596  }
597  }
598  }
599 
600  /* TODO add an editor to Pd
601  // only one editor can be open in the same time
602  if (!EXTRA->textEditor) {
603 
604  EXTRA->textEditor = (t_object*)object_new(_sym_nobox, _sym_jed, x, 0);
605 
606  buffer = new TTString();
607 
608  // get the buffer handler
609  tterr = x->internals->lookup(kTTSym_TextHandler, o);
610 
611  if (!tterr) {
612 
613  aTextHandler = o[0];
614 
615  critical_enter(0);
616  aTextHandler.set(kTTSym_object, *EXTRA->toEdit);
617  tterr = aTextHandler.send(kTTSym_Write, (TTPtr)buffer, none);
618  critical_exit(0);
619  }
620 
621  // pass the buffer to the editor
622  object_method(EXTRA->textEditor, _sym_settext, buffer->c_str(), _sym_utf_8);
623  object_attr_setchar(EXTRA->textEditor, gensym("scratch"), 1);
624 
625  snprintf(title, MAX_FILENAME_CHARS, "cuelist editor");
626  object_attr_setsym(EXTRA->textEditor, _sym_title, gensym(title));
627 
628  // output a flag
629  atom_setsym(&a, gensym("opened"));
630  outlet_anything((t_outlet*)x->dumpOut, gensym("editor"), 1, &a);
631 
632  buffer->clear();
633  delete buffer;
634  buffer = NULL;
635  }
636  */
637 }
638 
639 void cue_edclose(TTPtr self, char **text, long size)
640 {
642 
643  EXTRA->text = new TTString(*text);
644  EXTRA->textEditor = NULL;
645 
646  cue_doedit(x);
647 // defer_low((t_object*)x, (method)cue_doedit, NULL, 0, NULL);
648 }
649 
650 void cue_doedit(TTPtr self)
651 {
653  TTObject aTextHandler;
654  TTValue o, args, none;
655  t_atom a;
656  TTErr tterr;
657 
658  // get the buffer handler
659  tterr = x->internals->lookup(kTTSym_TextHandler, o);
660 
661  if (!tterr) {
662 
663  aTextHandler = o[0];
664 
665 // critical_enter(0);
666  tterr = aTextHandler.send(kTTSym_Read, (TTPtr)EXTRA->text, none);
667 // critical_exit(0);
668 
669  // output a flag
670  atom_setsym(&a, gensym("closed"));
671  outlet_anything((t_outlet*)x->dumpOut, gensym("editor"), 1, &a);
672 
673  if (tterr)
674  outlet_anything((t_outlet*)x->dumpOut, _sym_error, 0, NULL);
675  }
676 
677  delete EXTRA->text;
678  EXTRA->text = NULL;
679  EXTRA->textEditor = NULL;
680  *EXTRA->toEdit = x->wrappedObject;
681  EXTRA->cueName = kTTSymEmpty;
682 }
683 
684 t_max_err cue_get_relative(TTPtr self, TTPtr attr, long *ac, t_atom **av)
685 {
687 
688  if ((*ac)&&(*av)) {
689  //memory passed in, use it
690  } else {
691  //otherwise allocate memory
692  *ac = 1;
693  if (!(*av = (t_atom*)getbytes(sizeof(t_atom)*(*ac)))) {
694  *ac = 0;
695  return -4; // MAX_ERR_OUT_OF_MEM;
696  }
697  }
698 
699  atom_setlong(*av, x->index);
700 
701  return 0; // MAX_ERR_NONE;
702 }
703 
704 t_max_err cue_set_relative(TTPtr self, TTPtr attr, long ac, t_atom *av)
705 {
707 
708  if (ac&&av) {
709  x->index = atom_getlong(av);
710 
711  if (x->index) {
712  // The following must be deferred because we have to interrogate our box,
713  // and our box is not yet valid until we have finished instantiating the object.
714  // Trying to use a loadbang method instead is also not fully successful (as of Max 5.0.6)
715  cue_subscribe(x);
716 // defer_low((t_object*)x, (method)cue_subscribe, NULL, 0, 0);
717  }
718 
719  } else {
720  // no args
721  x->index = 0;
722  }
723  return 0; // MAX_ERR_NONE;
724 }
TTErr JAMOMA_EXPORT jamoma_patcher_get_info(t_object *obj, t_object **returnedPatcher, TTSymbol &returnedContext, TTSymbol &returnedClass, TTSymbol &returnedName)
Get all context info from an object (his patcher and the context, the class and the name of his patch...
TTAddress appendAddress(const TTAddress &toAppend)
Return a new TTAddress with the appended part.
Definition: TTAddress.h:167
TTObject subscriberObject
The instance of a TTSubscriber object used to register the wrapped object in the tree structure...
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
Definition: TTBase.h:167
TTErr send(const TTSymbol aName)
Send a message to this object with no arguments.
Definition: TTObject.cpp:135
TTHandle outlets
an array of outlet
TTErr lookup(const TTSymbol key, TTValue &value)
Find the value for the given key.
Definition: TTHash.cpp:76
We build a directory of TTNodes, and you can request a pointer for any TTNode, or add an observer to ...
Definition: TTNode.h:59
TTAddress address
sometime external needs to store an address (e.g. send, receive, view, ...)
TTSymbol patcherClass
the patcher class in which the external is
TTErr JAMOMA_EXPORT jamoma_cueManager_create(t_object *x, TTObject &returnedCueManager)
Create a #TTCueManager object.
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
TTObject & getObject()
Get the object binded by this node.
Definition: TTNode.cpp:468
size_type size() const noexcept
Return the number of elements.
Data structure for storing extra data.
void * extra
used to keep very specific things
t_object * patcherPtr
the patcher in which the external is (ignoring subpatcher)
TTSymbol JAMOMA_EXPORT jamoma_file_read(t_object *x, long argc, const t_atom *argv, t_fourcc filetype)
Get BOOT style filepath from args or, if no args open a dialog to read a file.
TTHashPtr internals
An hash table to store any internal TTObjectBases (like TTData, TTViewer, ...)
Maintain a collection of TTValue objects indexed by TTSymbol pointers.
Definition: TTHash.h:36
void prepend(const TTValue &aValueToPrepend)
Insert another TTValue before the first element.
Definition: TTValue.h:162
void append(const T &anElementValueToAppend)
Insert a single TTElement at the end.
Definition: TTValue.h:243
void * TTPtr
A generic pointer.
Definition: TTBase.h:248
TTErr get(const TTSymbol aName, T &aReturnedValue) const
Get an attribute value for an object.
void JAMOMA_EXPORT jamoma_ttvalue_to_Atom(const TTValue &v, long *argc, t_atom **argv)
Make an Atom array from a TTValue.
TTSymbol name() const
Return the name of this class.
Definition: TTObject.cpp:129
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...
Definition: TTSymbol.h:26
TTSymbol JAMOMA_EXPORT jamoma_file_write(t_object *x, long argc, const t_atom *argv, char *default_filename)
Get BOOT style filepath from args or, if no args open a dialog to write a file.
TTErr append(const TTSymbol key, const TTValue &value)
Insert an item into the hash table.
Definition: TTHash.cpp:70
void get(const TTUInt16 index, T &returnedElementValue) const
DEPRECATED.
Definition: TTValue.h:591
TTObject wrappedObject
The instance of the Jamoma object we are wrapping.
const char * c_str() const
Return a pointer to the internal string as a C-string.
Definition: TTSymbol.h:77
void JAMOMA_EXPORT jamoma_ttvalue_from_Atom(TTValue &v, t_symbol *msg, long argc, const t_atom *argv)
Make a TTValue from Atom array.
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...
Definition: TTBase.h:342
std::uint32_t TTUInt32
32 bit unsigned integer
Definition: TTBase.h:178
TTSymbol patcherContext
the patcher context in which the external is (model, view)
TTSymbol patcherName
the patcher name in which the external is
TTErr JAMOMA_EXPORT jamoma_subscriber_create(t_object *x, TTObject &anObject, TTAddress relativeAddress, TTObject &returnedSubscriber, TTSymbol &returnedAddress, TTNodePtr *returnedNode, TTNodePtr *returnedContextNode)
Create a #TTSubscriber object and register a TTObject into the tree or, if aTTObject is NULL...
The TTString class is used to represent a string.
Definition: TTString.h:34
long index
index of the inlet used
TTBoolean valid() const
Determine if the object contained by this TTObject is truly ready for use.
Definition: TTObject.cpp:179
WrappedModularInstance * WrappedModularInstancePtr
Pointer to a wrapped instance of our object.
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
TTErr wrapTTModularClassAsPdClass(TTSymbol &ttblueClassName, const char *pdClassName, WrappedClassPtr *c, ModularSpec *specificities)
Wrap a Jamoma class as a Pd class.