aboutsummaryrefslogtreecommitdiff
path: root/chaos/src/chaos_base.hpp
diff options
context:
space:
mode:
authorTim Blechmann <timblech@users.sourceforge.net>2004-12-23 10:07:17 +0000
committerIOhannes m zmölnig <zmoelnig@iem.at>2015-10-14 15:11:57 +0200
commit404bfef9e23dfc3166cb2005367e7e8a41863914 (patch)
tree3995ab20cf7ec984560c44e4fdeef1106ce8ff1c /chaos/src/chaos_base.hpp
parent5233c01a26329306c9f1d08c1a39733aee2cc518 (diff)
base class macros
svn path=/trunk/externals/tb/; revision=2426
Diffstat (limited to 'chaos/src/chaos_base.hpp')
-rw-r--r--chaos/src/chaos_base.hpp92
1 files changed, 90 insertions, 2 deletions
diff --git a/chaos/src/chaos_base.hpp b/chaos/src/chaos_base.hpp
index 231580b..a42e275 100644
--- a/chaos/src/chaos_base.hpp
+++ b/chaos/src/chaos_base.hpp
@@ -1,4 +1,4 @@
-//
+a//
//
// chaos~
// Copyright (C) 2004 Tim Blechmann
@@ -36,7 +36,6 @@ public:
return m_num_eq;
}
- /* prototype for system function */
virtual void m_step();
data_t * m_data; // state of the system
@@ -51,5 +50,94 @@ FLEXT_CALLGET_F(m_system->get_num_eq);
#define CHAOS_ATTRIBUTES \
FLEXT_ADDATTR_GET("dimension",m_system->get_num_eq);
+
+
+// macros for simplified system state functions
+#define CHAOS_SYS_SETFUNC(NAME, NR) \
+ void set_##NAME(t_float f) \
+ { \
+ m_data[NR] = (data_t) f; \
+ }
+
+#define CHAOS_SYS_SETFUNC_PRED(NAME, NR, PRED) \
+ void set_##NAME(t_float f) \
+ { \
+ if ( PRED(f) ) \
+ m_data[NR] = (data_t) f; \
+ else \
+ post("value for dimension " #NAME " %f out of range", f); \
+ }
+
+#define CHAOS_SYS_GETFUNC(NAME, NR) \
+ t_float get_##NAME() \
+ { \
+ return (t_float)m_data[NR]; \
+ }
+
+/* to be called in the public part */
+#define CHAOS_SYSVAR_FUNCS_PRED(NAME, NR, PRED) \
+public: \
+CHAOS_SYS_SETFUNC_PRED(NAME, NR, PRED) \
+CHAOS_SYS_GETFUNC(NAME, NR)
+
+#define CHAOS_SYSVAR_FUNCS(NAME, NR) \
+public: \
+CHAOS_SYS_SETFUNC(NAME, NR) \
+CHAOS_SYS_GETFUNC(NAME, NR)
+
+
+
+// macros for simplified system parameter functions
+#define CHAOS_PAR_SETFUNC(NAME) \
+ void set_##NAME(t_float f) \
+ { \
+ m_##NAME = (data_t) f; \
+ }
+
+#define CHAOS_PAR_SETFUNC_PRED(NAME, PRED) \
+ void set_##NAME(t_float f) \
+ { \
+ if ( PRED(f) ) \
+ m_##NAME = (data_t) f; \
+ else \
+ post("value for parameter " #NAME " %f out of range", f); \
+ }
+
+#define CHAOS_PAR_GETFUNC(NAME) \
+ t_float get_##NAME() \
+ { \
+ return (t_float)m_##NAME; \
+ }
+
+
+#define CHAOS_SYSPAR_FUNCS_PRED(NAME, PRED) \
+public: \
+CHAOS_PAR_SETFUNC_PRED(NAME, PRED) \
+CHAOS_PAR_GETFUNC(NAME) \
+private: \
+data_t m_##NAME; \
+public:
+
+#define CHAOS_SYSPAR_FUNCS(NAME) \
+public: \
+CHAOS_PAR_SETFUNC(NAME) \
+CHAOS_PAR_GETFUNC(NAME) \
+private: \
+data_t m_##NAME; \
+public:
+
+
+#define CHAOS_SYS_CALLBACKS(NAME) \
+FLEXT_CALLVAR_F(m_system->get_##NAME, m_system->set_##NAME);
+
+#define CHAOS_SYS_ATTRIBUTE(NAME) \
+FLEXT_ADDATTR_VAR(#NAME,m_system->get_##NAME, m_system->set_##NAME);
+
+#define CHAOS_SYS_INIT(NAME, VALUE) \
+set_##NAME(VALUE);
+
+#define CHAOS_PARAMETER(NAME) m_##NAME
+
+
#define __chaos_base_hpp
#endif /* __chaos_base_hpp */