34 void *init_new(t_symbol* s,
long argc, t_atom* argv);
35 void init_free(t_init *x);
36 void init_assist(t_init *x,
void *b,
long m,
long a,
char *s);
37 void init_subscribe(t_init *x);
38 void init_return_address(t_init *x, t_symbol *msg,
long argc, t_atom *argv);
39 void init_return_value(t_init *x, t_symbol *msg,
long argc, t_atom *argv);
43 t_class *g_init_class;
49 int JAMOMA_EXPORT_MAXOBJ
main(
void)
54 common_symbols_init();
57 c = class_new(
"j.init",(method)init_new, (method)init_free,
sizeof(t_init), (method)0L, A_GIMME, 0);
61 class_addmethod(c, (method)init_return_address,
"return_address", A_CANT, 0);
62 class_addmethod(c, (method)init_return_value,
"return_value", A_CANT, 0);
63 class_addmethod(c, (method)init_assist,
"assist", A_CANT, 0L);
66 class_register(CLASS_BOX, c);
77 void *init_new(t_symbol *s,
long argc, t_atom *argv)
79 long attrstart = attr_args_offset(argc, argv);
80 t_init *x = (t_init *)object_alloc(g_init_class);
81 t_symbol *relativeAddress = _sym_nothing;
83 if (attrstart && argv)
84 atom_arg_getsym(&relativeAddress, 0, attrstart, argv);
88 x->outlets = (TTHandle)sysmem_newptr(
sizeof(
TTPtr) * 2);
89 x->outlets[end_out] = bangout(x);
90 x->outlets[start_out] = bangout(x);
92 x->patcherNode = NULL;
95 attr_args_process(x, argc, argv);
100 defer_low((t_object*)x, (method)init_subscribe, NULL, 0, 0);
106 void init_free(t_init *x)
109 x->initReceiver.set(kTTSym_address, kTTAdrsEmpty);
122 void init_assist(t_init *x,
void *b,
long msg,
long arg,
char *dst)
128 strcpy(dst,
"bang when initialization starts");
130 strcpy(dst,
"bang when initilization is done");
134 void init_subscribe(t_init *x)
141 TTObject returnAddressCallback, returnValueCallback, empty;
146 if (!
jamoma_subscriber_create((t_object*)x, empty, x->address, x->subscriberObject, returnedAddress, &returnedNode, &returnedContextNode)) {
150 x->subscriberObject.
get(
"contextAddress", v);
151 contextAddress = v[0];
155 if (contextAddress != kTTAdrsEmpty) {
158 returnAddressCallback =
TTObject(
"callback");
159 returnAddressCallback.
set(kTTSym_baton,
TTPtr(x));
161 args.
append(returnAddressCallback);
163 returnValueCallback =
TTObject(
"callback");
164 returnValueCallback.
set(kTTSym_baton,
TTPtr(x));
166 args.
append(returnValueCallback);
168 x->initReceiver =
TTObject(kTTSym_Receiver, args);
170 x->initReceiver.set(kTTSym_address, contextAddress.
appendAttribute(kTTSym_initialized));
186 defer_low((t_object*)x, (method)init_subscribe, NULL, 0, 0);
190 object_error((t_object*)x,
"can't bind because %s is not a relative address", x->address.c_str());
193 void init_return_address(t_init *x, t_symbol *msg,
long argc, t_atom *argv)
199 void init_return_value(t_init *x, t_symbol *msg,
long argc, t_atom *argv)
201 if (atom_gettype(argv) == A_LONG) {
203 if (atom_getlong(argv) == 0)
204 outlet_bang(x->outlets[start_out]);
206 outlet_bang(x->outlets[end_out]);
TTAddress appendAttribute(TTSymbol anAttribute)
Return a new TTAddress with attribute part.
We build a directory of TTNodes, and you can request a pointer for any TTNode, or add an observer to ...
int JAMOMA_EXPORT_MAXOBJ main(void)
Set up this class as a Max external the first time an object of this kind is instantiated.
The TTAddress class is used to represent a string and efficiently pass and compare that string...
Create and use Jamoma object instances.
this flag means that an address have no leading slash
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.
TTErr set(const TTSymbol aName, T aValue)
Set an attribute value for an object.
[doxygenAppendixC_copyExample]