diff options
Diffstat (limited to 'Gem/develop/include/Gem/RTE/MessageCallbacks.h')
-rw-r--r-- | Gem/develop/include/Gem/RTE/MessageCallbacks.h | 140 |
1 files changed, 91 insertions, 49 deletions
diff --git a/Gem/develop/include/Gem/RTE/MessageCallbacks.h b/Gem/develop/include/Gem/RTE/MessageCallbacks.h index 79e174e..9fa57cd 100644 --- a/Gem/develop/include/Gem/RTE/MessageCallbacks.h +++ b/Gem/develop/include/Gem/RTE/MessageCallbacks.h @@ -32,55 +32,97 @@ #ifndef _INCLUDE__GEM_RTE_MESSAGECALLBACKS_H_ #define _INCLUDE__GEM_RTE_MESSAGECALLBACKS_H_ -namespace gem { - namespace RteMess { - class NoneType {}; // just a dummy class - template<class T=NoneType, class T1=T> - struct TypeTemplateCore{ - static t_atomtype atomtype_id(void) { return A_NULL; } - static T1 cast(T value) { return static_cast<T1>(value); } - typedef T proxyType; - virtual ~TypeTemplateCore(void) { } - }; - template<class T> - struct TypeTemplate : TypeTemplateCore<T, T> { - }; - template<> - struct TypeTemplate<float> : TypeTemplateCore<t_float, float> { - static t_atomtype atomtype_id(void) { return A_FLOAT; } - }; - template<> - struct TypeTemplate<double> : TypeTemplateCore<t_float, double> { - static t_atomtype atomtype_id(void) { return A_FLOAT; } - }; - template<> - struct TypeTemplate<t_int> : TypeTemplateCore<t_float, t_int> { - static t_atomtype atomtype_id(void) { return A_FLOAT; } - }; - template<> - struct TypeTemplate<int> : TypeTemplateCore<t_float, int> { - static t_atomtype atomtype_id(void) { return A_FLOAT; } - }; - template<> - struct TypeTemplate<unsigned int> : TypeTemplateCore<t_float, unsigned int> { - static t_atomtype atomtype_id(void) { return A_FLOAT; } - static unsigned int cast(t_float f) { return (f>0.)?static_cast<unsigned int>(f):0; } - }; - template<> - struct TypeTemplate<bool> : TypeTemplateCore<t_float, bool> { - static t_atomtype atomtype_id(void) { return A_FLOAT; } - static bool cast(t_float f) {return (f>0.5); } - }; - template<> - struct TypeTemplate<t_symbol*> : TypeTemplateCore<t_symbol*> { - static t_atomtype atomtype_id(void) { return A_DEFSYMBOL; } - }; - template<> - struct TypeTemplate<std::string> : TypeTemplateCore<t_symbol*, std::string> { - static t_atomtype atomtype_id(void) { return A_DEFSYMBOL; } - static std::string cast(t_symbol*s) {return std::string(s->s_name); } - }; - }; }; +namespace gem +{ +namespace RteMess +{ +class NoneType {}; // just a dummy class +template<class T=NoneType, class T1=T> +struct TypeTemplateCore { + static t_atomtype atomtype_id(void) + { + return A_NULL; + } + static T1 cast(T value) + { + return static_cast<T1>(value); + } + typedef T proxyType; + virtual ~TypeTemplateCore(void) { } +}; +template<class T> +struct TypeTemplate : TypeTemplateCore<T, T> { +}; +template<> +struct TypeTemplate<float> : TypeTemplateCore<t_float, float> { + static t_atomtype atomtype_id(void) + { + return A_FLOAT; + } +}; +template<> +struct TypeTemplate<double> : TypeTemplateCore<t_float, double> { + static t_atomtype atomtype_id(void) + { + return A_FLOAT; + } +}; +template<> +struct TypeTemplate<t_int> : TypeTemplateCore<t_float, t_int> { + static t_atomtype atomtype_id(void) + { + return A_FLOAT; + } +}; +template<> +struct TypeTemplate<int> : TypeTemplateCore<t_float, int> { + static t_atomtype atomtype_id(void) + { + return A_FLOAT; + } +}; +template<> +struct TypeTemplate<unsigned int> : TypeTemplateCore<t_float, unsigned int> { + static t_atomtype atomtype_id(void) + { + return A_FLOAT; + } + static unsigned int cast(t_float f) + { + return (f>0.)?static_cast<unsigned int>(f):0; + } +}; +template<> +struct TypeTemplate<bool> : TypeTemplateCore<t_float, bool> { + static t_atomtype atomtype_id(void) + { + return A_FLOAT; + } + static bool cast(t_float f) + { + return (f>0.5); + } +}; +template<> +struct TypeTemplate<t_symbol*> : TypeTemplateCore<t_symbol*> { + static t_atomtype atomtype_id(void) + { + return A_DEFSYMBOL; + } +}; +template<> +struct TypeTemplate<std::string> : TypeTemplateCore<t_symbol*, std::string> { + static t_atomtype atomtype_id(void) + { + return A_DEFSYMBOL; + } + static std::string cast(t_symbol*s) + { + return std::string(s->s_name); + } +}; +}; +}; #define MSG_CONCAT3(a, b, c) _##a##_##b##_##c |