aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/tutorial/bind1
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill/flext/tutorial/bind1')
-rwxr-xr-xexternals/grill/flext/tutorial/bind1/main.cpp144
1 files changed, 63 insertions, 81 deletions
diff --git a/externals/grill/flext/tutorial/bind1/main.cpp b/externals/grill/flext/tutorial/bind1/main.cpp
index 2532556a..debfa68a 100755
--- a/externals/grill/flext/tutorial/bind1/main.cpp
+++ b/externals/grill/flext/tutorial/bind1/main.cpp
@@ -31,11 +31,19 @@ class bind1:
public:
// constructor with no arguments
- bind1();
+ bind1()
+ {
+ // define inlets:
+ // first inlet must always be of type anything (or signal for dsp objects)
+ AddInAnything("message inlet"); // add one inlet for any message
+ AddInAnything("forwarding inlet"); // add one inlet for any message
+
+ AddOutAnything("bound message"); // output received bound message
+ }
/*
- no constructor necessary here:
- flext frees all eventually still bound symbols when the object is destroyed
+ no destructor necessary here:
+ flext frees all eventually remaining bound symbols when the object is destroyed
(but NOT the data that can be passed via the FLEXT_BINDMETHOD call!)
*/
@@ -44,25 +52,69 @@ protected:
buffer *buf;
// bind object
- void m_bind(const t_symbol *s);
+ void m_bind(const t_symbol *s)
+ {
+ if(!Bind(s)) {
+ post("%s (%s) - Binding failed",thisName(),GetString(thisTag()));
+ }
+ }
+
// unbind object
- void m_unbind(const t_symbol *s);
+ void m_unbind(const t_symbol *s)
+ {
+ if(!Unbind(s)) {
+ post("%s (%s) - Binding failed",thisName(),GetString(thisTag()));
+ }
+ }
+
// bind method
- void m_bindmethod(const t_symbol *s);
+ void m_bindmethod(const t_symbol *s)
+ {
+ if(!FLEXT_BINDMETHOD(s,m_bound,NULL)) {
+ post("%s (%s) - Binding failed",thisName(),GetString(thisTag()));
+ }
+ }
+
// unbind method
- void m_unbindmethod(const t_symbol *s);
+ void m_unbindmethod(const t_symbol *s)
+ {
+ if(!FLEXT_UNBINDMETHOD(s)) {
+ post("%s (%s) - Binding failed",thisName(),GetString(thisTag()));
+ }
+ }
// forward message
- void m_forward(const t_symbol *s,int argc,const t_atom *argv);
+ void m_forward(const t_symbol *s,int argc,const t_atom *argv)
+ {
+ Forward(s,argc,argv);
+ }
// method for symbol-bound messages
- void m_bound(const t_symbol *sym,int argc,const t_atom *argv,void *data);
+ void m_bound(const t_symbol *sym,int argc,const t_atom *argv,void *data)
+ {
+ ToOutAnything(0,sym,argc,argv);
+ }
// method for binding test
- void m_test(float value);
+ void m_test(float value)
+ {
+ post("%s - TEST METHOD: value %f",thisName(),value);
+ }
private:
- static void setup(t_classid c);
+ static void setup(t_classid c)
+ {
+ // register methods
+
+ FLEXT_CADDMETHOD_(c,0,"bind",m_bind); // register method "bind" for inlet 0
+ FLEXT_CADDMETHOD_(c,0,"unbind",m_unbind); // register method "unbind" for inlet 0
+ FLEXT_CADDMETHOD_(c,0,"bindmethod",m_bindmethod); // register method "bindmethod" for inlet 0
+ FLEXT_CADDMETHOD_(c,0,"unbindmethod",m_unbindmethod); // register method "unbindmethod" for inlet 0
+
+ FLEXT_CADDMETHOD_(c,0,"test",m_test); // register method m_test for inlet 0
+
+ FLEXT_CADDMETHOD(c,1,m_forward); // register method m_forward for inlet 1
+ }
FLEXT_CALLBACK_S(m_bind) // wrapper for method m_bind (with symbol argument)
FLEXT_CALLBACK_S(m_unbind) // wrapper for method m_unbind (with symbol argument)
@@ -79,74 +131,4 @@ private:
FLEXT_NEW("bind1",bind1)
-void bind1::setup(t_classid c)
-{
- // register methods
-
- FLEXT_CADDMETHOD_(c,0,"bind",m_bind); // register method "bind" for inlet 0
- FLEXT_CADDMETHOD_(c,0,"unbind",m_unbind); // register method "unbind" for inlet 0
- FLEXT_CADDMETHOD_(c,0,"bindmethod",m_bindmethod); // register method "bindmethod" for inlet 0
- FLEXT_CADDMETHOD_(c,0,"unbindmethod",m_unbindmethod); // register method "unbindmethod" for inlet 0
-
- FLEXT_CADDMETHOD_(c,0,"test",m_test); // register method m_test for inlet 0
-
- FLEXT_CADDMETHOD(c,1,m_forward); // register method m_forward for inlet 1
-}
-
-
-bind1::bind1()
-{
- // define inlets:
- // first inlet must always be of type anything (or signal for dsp objects)
- AddInAnything("message inlet"); // add one inlet for any message
- AddInAnything("forwarding inlet"); // add one inlet for any message
-
- AddOutAnything("bound message"); // output received bound message
-}
-
-
-void bind1::m_bind(const t_symbol *s)
-{
- if(!Bind(s)) {
- post("%s (%s) - Binding failed",thisName(),GetString(thisTag()));
- }
-}
-
-void bind1::m_unbind(const t_symbol *s)
-{
- if(!Unbind(s)) {
- post("%s (%s) - Binding failed",thisName(),GetString(thisTag()));
- }
-}
-
-void bind1::m_bindmethod(const t_symbol *s)
-{
- if(!FLEXT_BINDMETHOD(s,m_bound,NULL)) {
- post("%s (%s) - Binding failed",thisName(),GetString(thisTag()));
- }
-}
-
-void bind1::m_unbindmethod(const t_symbol *s)
-{
- if(!FLEXT_UNBINDMETHOD(s)) {
- post("%s (%s) - Binding failed",thisName(),GetString(thisTag()));
- }
-}
-
-void bind1::m_forward(const t_symbol *s,int argc,const t_atom *argv)
-{
- Forward(s,argc,argv);
-}
-
-
-void bind1::m_bound(const t_symbol *sym,int argc,const t_atom *argv,void *data)
-{
- ToOutAnything(0,sym,argc,argv);
-}
-
-void bind1::m_test(float value)
-{
- post("%s - TEST METHOD: value %f",thisName(),value);
-}
-