aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas O Fredericks <mrtof@users.sourceforge.net>2009-10-21 22:37:36 +0000
committerThomas O Fredericks <mrtof@users.sourceforge.net>2009-10-21 22:37:36 +0000
commit99b0b62ca25ec04b1629691a3644fdc513a52924 (patch)
tree688d0ac3575d19d7c9033f66c29e9cbc53cb5601 /src
parent4d1507c165853e01072fa166ccd36842d3574822 (diff)
Replaced paramGui abstraction by a class
svn path=/trunk/externals/tof/; revision=12629
Diffstat (limited to 'src')
-rw-r--r--src/Makefile2
-rw-r--r--src/param.c21
-rw-r--r--src/param.h22
-rw-r--r--src/paramCustom.c3
-rw-r--r--src/paramDump.c96
-rw-r--r--src/paramRoute.c2
-rw-r--r--src/tof.h9
7 files changed, 120 insertions, 35 deletions
diff --git a/src/Makefile b/src/Makefile
index 31b2c9f..62e263d 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,6 +1,6 @@
default:
-PARAM: param paramDump paramRoute paramFile paramCustom paramId
+PARAM: param paramDump paramRoute paramFile paramCustom paramId paramGui
current:
echo make class
diff --git a/src/param.c b/src/param.c
index 473f172..5326913 100644
--- a/src/param.c
+++ b/src/param.c
@@ -20,7 +20,6 @@
*/
-#include "tof.h"
#include "param.h"
extern int sys_noloadbang;
@@ -151,12 +150,19 @@ static void paramClass_save(t_paramClass *x, t_binbuf* bb,int f) {
}
// SPECIAL PARAM GUI FUNCTION
-static void paramClass_GUI(t_paramClass *x, int* ac, t_atom** av) {
+static void paramClass_GUI(t_paramClass *x, int* ac, t_atom** av, t_symbol** send,t_symbol** receive) {
*ac = x->gac;
*av = x->gav;
+ *send = x->receive;
+ *receive = x->send;
}
+// SPECIAL PARAM GUI FUNCTION
+static void paramClass_GUIUpdate(t_paramClass *x) {
+ if(x->selector != &s_bang ) tof_send_anything_prepend(x->send,x->selector,x->ac,x->av,x->set_s );
+}
+
// CONSTRUCTOR
static void* paramClass_new(t_symbol *s, int ac, t_atom *av)
@@ -214,7 +220,8 @@ static void* paramClass_new(t_symbol *s, int ac, t_atom *av)
x->param = param_register(x,root,path, \
(t_paramGetMethod) paramClass_get, \
paramSaveMethod, \
- paramGUIMethod);
+ paramGUIMethod,\
+ (t_paramGUIUpdateMethod)paramClass_GUIUpdate);
if (!x->param) return NULL;
@@ -247,15 +254,7 @@ static void* paramClass_new(t_symbol *s, int ac, t_atom *av)
//}
}
-
-
-
-
-
-
-
-
int l = strlen(path->s_name) + strlen(root->s_name) + 2;
char* receiver = getbytes( l * sizeof(*receiver));
diff --git a/src/param.h b/src/param.h
index 9782ee1..c4e0ead 100644
--- a/src/param.h
+++ b/src/param.h
@@ -1,8 +1,11 @@
+#include "tof.h"
+
//#define PARAMDEBUG
typedef void (*t_paramGetMethod)(void*,t_symbol**,int*,t_atom**);
typedef void (*t_paramSaveMethod)(void*,t_binbuf*,int);
-typedef void (*t_paramGUIMethod)(void*,int*,t_atom**);
+typedef void (*t_paramGUIMethod)(void*,int*,t_atom**,t_symbol**,t_symbol**);
+typedef void (*t_paramGUIUpdateMethod)(void*);
char param_buf_temp_a[MAXPDSTRING];
char param_buf_temp_b[MAXPDSTRING];
@@ -21,6 +24,7 @@ typedef struct _param {
t_paramGetMethod get; //Function to get current value
t_paramSaveMethod save; //Function to save
t_paramGUIMethod GUI;
+ t_paramGUIUpdateMethod GUIUpdate;
//t_symbol* send;
//t_symbol* receive;
} t_param;
@@ -140,10 +144,11 @@ static t_symbol* param_get_name ( int ac, t_atom* av ) {
char* name = atom_getsymbol(av)->s_name;
if (*name == *param_separator ) {
int length = strlen(name);
- if (name[length-1] != '_') return atom_getsymbol(av);
+ if (name[length-1] != '_' || name[length-1] != '/') return atom_getsymbol(av);
}
}
- post("param names must start with a \"/\" and can not end with a \"_\"!");
+ post("param names must start with a \"/\" and can not end with \
+ either a \"_\" or a \"/\"!");
return NULL;
}
@@ -205,9 +210,14 @@ static t_symbol* param_get_path( t_canvas* i_canvas, t_symbol* name) {
}
i_canvas = i_canvas->gl_owner;
}
- //strcat(sbuf_name,separator);
+
+ // If no name, the path will always end with a /
+
if ( name != NULL) {
strcat(sbuf_name,name->s_name);
+ } else {
+ //if (strlen(sbuf_name)==0)
+ strcat(sbuf_name,param_separator);
}
return gensym(sbuf_name);
@@ -222,7 +232,8 @@ static t_symbol* param_get_path( t_canvas* i_canvas, t_symbol* name) {
//static struct param* register_param( t_canvas* canvas, int o_ac, t_atom* o_av) {
static t_param* param_register(void* x,t_symbol* root, t_symbol* path,\
- t_paramGetMethod get, t_paramSaveMethod save, t_paramGUIMethod GUI) {
+ t_paramGetMethod get, t_paramSaveMethod save, t_paramGUIMethod GUI, \
+ t_paramGUIUpdateMethod GUIUpdate) {
//char *separator = "/";
@@ -263,6 +274,7 @@ static t_param* param_register(void* x,t_symbol* root, t_symbol* path,\
p->get = get;
p->save = save;
p->GUI = GUI;
+ p->GUIUpdate = GUIUpdate;
//p->id = id;
//set_param( p, ac, av);
//p->ac_g = ac_g;
diff --git a/src/paramCustom.c b/src/paramCustom.c
index 9b23461..8be3360 100644
--- a/src/paramCustom.c
+++ b/src/paramCustom.c
@@ -138,10 +138,11 @@ static void* paramCustom_new(t_symbol *s, int ac, t_atom *av)
x->nopresets = tof_find_tag('/',gensym("/nps"), ac-1, av+1);
-
+
x->param = param_register(x,root,path,\
NULL,\
(t_paramSaveMethod) paramCustom_save,\
+ NULL,\
NULL);
if (!x->param) return NULL;
diff --git a/src/paramDump.c b/src/paramDump.c
index b9f73b9..91b321e 100644
--- a/src/paramDump.c
+++ b/src/paramDump.c
@@ -29,35 +29,102 @@ static t_class *paramDump_class;
typedef struct _paramDump
{
- t_object x_obj;
- t_outlet* outlet;
- //t_symbol* s_set;
+ t_object x_obj;
+ t_outlet* outlet;
+ t_symbol* empty_s;
t_symbol* root;
+
} t_paramDump;
+static void paramDump_updateguis(t_paramDump *x, t_symbol* s) {
+
+ t_param* p = get_param_list(x->root);
+ int ac;
+ t_atom* av;
+
+ if ( s == x->empty_s ) {
+ while (p) {
+ if (p->GUIUpdate) {
+ p->GUIUpdate(p->x);
+ }
+ p = p->next;
+ }
+ } else {
+ int length = strlen(s->s_name);
+ while (p) {
+ if (p->GUIUpdate && (strncmp(p->path->s_name,s->s_name,length)==0) ) {
+ p->GUIUpdate(p->x);
+
+ }
+ p = p->next;
+ }
+ }
+
+}
static void paramDump_guis(t_paramDump *x, t_symbol* s) {
+ t_param* p = get_param_list(x->root);
+ int ac;
+ t_atom* av;
+ t_symbol* send;
+ t_symbol* receive;
-
- t_param* p = get_param_list(x->root);
- int ac;
- t_atom* av;
-
+ if ( s == x->empty_s ) {
while (p) {
if (p->GUI ) {
- p->GUI(p->x,&ac,&av);
+ p->GUI(p->x,&ac,&av,&send,&receive);
outlet_anything(x->outlet,p->path,ac,av);
}
p = p->next;
}
+ } else {
+ int length = strlen(s->s_name);
+ while (p) {
+ if (p->GUI && (strncmp(p->path->s_name,s->s_name,length)==0) ) {
+ p->GUI(p->x,&ac,&av,&send,&receive);
+ outlet_anything(x->outlet,p->path,ac,av);
+
+ }
+ p = p->next;
+ }
+ }
}
-// Dump out everything (OR THE ID'S OR JUST THE NAMES?)
+static void paramDump_symbol(t_paramDump *x, t_symbol* s) {
+
+ t_param* p = get_param_list(x->root);
+ #ifdef PARAMDEBUG
+ if (p == NULL) {
+ post("No params found");
+ } else {
+ post("Found params");
+ }
+ #endif
+
+ t_symbol* selector;
+ int ac;
+ t_atom* av;
+
+
+
+ int length = strlen(s->s_name);
+
+ while (p) {
+ if ( p->get && (strncmp(p->path->s_name,s->s_name,length)==0) ) {
+ p->get(p->x, &selector, &ac, &av);
+ tof_outlet_anything_prepend(x->outlet,selector,ac,av,p->path);
+ }
+ p = p->next;
+ }
+
+}
+
+// Dump out
static void paramDump_bang(t_paramDump *x) {
t_param* p = get_param_list(x->root);
@@ -73,6 +140,7 @@ static void paramDump_bang(t_paramDump *x) {
int ac;
t_atom* av;
+
while (p) {
if ( p->get ) {
p->get(p->x, &selector, &ac, &av);
@@ -97,7 +165,7 @@ static void *paramDump_new(t_symbol *s, int ac, t_atom *av) {
t_paramDump *x = (t_paramDump *)pd_new(paramDump_class);
x->root = tof_get_dollarzero(tof_get_root_canvas(tof_get_canvas()));
-
+ x->empty_s = gensym("");
//x->s_set = gensym("set");
@@ -112,10 +180,14 @@ void paramDump_setup(void) {
sizeof(t_paramDump), 0, A_GIMME, 0);
class_addbang(paramDump_class, paramDump_bang);
-
+ class_addsymbol(paramDump_class, paramDump_symbol);
+
//class_addmethod(paramDump_class, (t_method) paramDump_values, gensym("values"), A_DEFSYMBOL,0);
class_addmethod(paramDump_class, (t_method) paramDump_guis, gensym("guis"), A_DEFSYMBOL,0);
+ class_addmethod(paramDump_class, (t_method) paramDump_updateguis, gensym("updateguis"), A_DEFSYMBOL,0);
+
+
//class_addmethod(paramDump_class, (t_method) paramDump_update_guis, gensym("update"), A_DEFSYMBOL,0);
}
diff --git a/src/paramRoute.c b/src/paramRoute.c
index cc02cfe..92628b1 100644
--- a/src/paramRoute.c
+++ b/src/paramRoute.c
@@ -76,7 +76,7 @@ static void paramRoute_anything(t_paramRoute *x, t_symbol *s, int ac, t_atom *av
strcpy(param_buf_temp_a, x->root->s_name);
strcpy(param_buf_temp_b, x->path->s_name);
- strcat(param_buf_temp_b, s->s_name);
+ strcat(param_buf_temp_b, s->s_name+1);
t_symbol* path = gensym(param_buf_temp_b);
strcat(param_buf_temp_a, param_buf_temp_b);
t_symbol* target = gensym(param_buf_temp_a);
diff --git a/src/tof.h b/src/tof.h
index ae4e1ac..3c3b1f9 100644
--- a/src/tof.h
+++ b/src/tof.h
@@ -8,7 +8,7 @@
#define IS_A_SYMBOL(atom,index) ((atom+index)->a_type == A_SYMBOL)
#define IS_A_FLOAT(atom,index) ((atom+index)->a_type == A_FLOAT)
-#endif
+
char tof_buf_temp_a[MAXPDSTRING];
@@ -270,16 +270,16 @@ static void tof_outlet_anything_prepend(t_outlet* outlet, t_symbol* s, int argc,
}
-static void tof_send_anything_prepend(t_symbol* target,t_symbol* s, int ac, t_atom* av,t_symbol* prepend) {
+static void tof_send_anything_prepend(t_symbol* target,t_symbol* selector, int ac, t_atom* av,t_symbol* prepend) {
if (target->s_thing) {
- if ( s == &s_list || s == &s_float || s == &s_symbol ) {
+ if ( selector == &s_list || selector == &s_float || selector == &s_symbol ) {
typedmess(target->s_thing, prepend, ac, av);
} else {
int new_ac = ac + 1;
t_atom *new_av = getbytes(new_ac*sizeof(*new_av));
tof_copy_atoms(av,new_av+1,ac);
- SETSYMBOL(new_av, s);
+ SETSYMBOL(new_av, selector);
typedmess(target->s_thing, prepend, new_ac, new_av);
freebytes(new_av, new_ac*sizeof(*new_av));
}
@@ -301,3 +301,4 @@ static t_symbol* tof_remove_extension(t_symbol* s) {
freebytes(newstring,length * sizeof(*newstring));
return newsymbol;
}
+#endif