Max 5 API Reference
00001 #ifndef __GLOBALSYMBOL_H__ 00002 #define __GLOBALSYMBOL_H__ 00003 00004 BEGIN_USING_C_LINKAGE 00005 00006 00007 // private 00008 void globalsymbol_initclass(); 00009 00010 00011 /** Get a reference to an object that is bound to a #t_symbol. 00012 @ingroup misc 00013 @param x The object that is getting the reference to the symbol. 00014 @param name The name of the symbol to reference. 00015 @param classname The name of the class of which the object we are referencing should be an instance. 00016 @return The s_thing of the #t_symbol. 00017 00018 @remark An example of real-world use is to get the buffer~ object associated with a symbol. 00019 @code 00020 // the struct of our object 00021 typedef struct _myobject { 00022 t_object obj; 00023 t_symbol *buffer_name; 00024 t_buffer *buffer_object; 00025 } t_myobject; 00026 00027 void myobject_setbuffer(t_myobject *x, t_symbol *s, long argc, t_atom *argv) 00028 { 00029 if(s != x->buffer_name){ 00030 // Reference the buffer associated with the incoming name 00031 x->buffer_object = (t_buffer *)globalsymbol_reference((t_object *)x, s->s_name, "buffer~"); 00032 00033 // If we were previously referenceing another buffer, we should not longer reference it. 00034 globalsymbol_dereference((t_object *)x, x->buffer_name->s_name, "buffer~"); 00035 00036 x->buffer_name = s; 00037 } 00038 } 00039 @endcode 00040 */ 00041 void *globalsymbol_reference(t_object *x, char *name, char *classname); 00042 00043 00044 /** Stop referencing an object that is bound to a #t_symbol, previously referenced using globalsymbol_reference(). 00045 @ingroup misc 00046 @param x The object that is getting the reference to the symbol. 00047 @param name The name of the symbol to reference. 00048 @param classname The name of the class of which the object we are referencing should be an instance. 00049 @see globalsymbol_reference() 00050 */ 00051 void globalsymbol_dereference(t_object *x, char *name, char *classname); 00052 00053 00054 /** Bind an object to a #t_symbol. 00055 @ingroup misc 00056 @param x The object to bind to the #t_symbol. 00057 @param name The name of the #t_symbol to which the object will be bound. 00058 @param flags Pass 0. 00059 @return A Max error code. 00060 */ 00061 t_max_err globalsymbol_bind(t_object *x, char *name, long flags); 00062 00063 00064 /** Remove an object from being bound to a #t_symbol. 00065 @ingroup misc 00066 @param x The object from which to unbind the #t_symbol. 00067 @param name The name of the #t_symbol from which the object will be unbound. 00068 @param flags Pass 0. 00069 */ 00070 void globalsymbol_unbind(t_object *x, char *name, long flags); 00071 00072 00073 // private 00074 void globalsymbol_notify(t_object *x, char *name, t_symbol *msg, void *data); 00075 00076 00077 END_USING_C_LINKAGE 00078 00079 #endif // __GLOBALSYMBOL_H__ 00080
Copyright © 2008, Cycling '74