7 #ifndef __FWCAMP_MACROS_HPP__ 8 #define __FWCAMP_MACROS_HPP__ 10 #ifndef CAMP_COMPILATION 12 #define fwCampAutoDeclareMacro( desc, export) 13 #define fwCampAutoDeclareDataMacro( desc, export) 14 #define fwCampMakeFriendDataMacro(desc) 20 #include <boost/preprocessor/seq/fold_left.hpp> 22 #include <camp/camptype.hpp> 23 #include <camp/class.hpp> 24 #include <camp/enum.hpp> 26 #define __FWCAMP_CAT(_s_, _state_, _elem_) BOOST_PP_CAT(_state_, _elem_) 27 #define __FWCAMP_NAMESPACE_CAT(_s_, _state_, _elem_) _state_::_elem_ 29 #define __FWCAMP_FUNC_SUFFIX(desc) \ 30 BOOST_PP_SEQ_FOLD_LEFT( __FWCAMP_CAT, BOOST_PP_SEQ_HEAD(desc), BOOST_PP_SEQ_TAIL(desc)) 32 #define __FWCAMP_NAMESPACE_NAME(desc) \ 33 ::BOOST_PP_SEQ_FOLD_LEFT( __FWCAMP_NAMESPACE_CAT, BOOST_PP_SEQ_HEAD(desc), BOOST_PP_SEQ_TAIL(desc)) 35 #define __FWCAMP_DECLARE_FUNC_NAME(desc) BOOST_PP_CAT(fwCampDeclare, __FWCAMP_FUNC_SUFFIX(desc)) 36 #define __FWCAMP_DECLARE_LOCAL_FUNC_NAME(desc) BOOST_PP_CAT(localDeclare, __FWCAMP_FUNC_SUFFIX(desc)) 38 #define __FWCAMP_CLASS_BUILDER_TYPE(desc) \ 39 camp::ClassBuilder < __FWCAMP_NAMESPACE_NAME(desc) > 41 #define __FWCAMP_AUTO_TYPE_NONCOPYABLE(type, registerFunc) \ 42 CAMP_TYPE_NONCOPYABLE( type) 44 #define __FWCAMP__AUTO__DECLARE__MACRO(desc) \ 45 void __FWCAMP_DECLARE_FUNC_NAME(desc)(__FWCAMP_CLASS_BUILDER_TYPE(desc) &); \ 46 inline void __FWCAMP_DECLARE_LOCAL_FUNC_NAME(desc)() \ 48 __FWCAMP_CLASS_BUILDER_TYPE(desc) builder = \ 49 camp::Class::declare< __FWCAMP_NAMESPACE_NAME(desc) >(BOOST_PP_STRINGIZE( __FWCAMP_NAMESPACE_NAME( \ 51 __FWCAMP_DECLARE_FUNC_NAME(desc)(builder); \ 53 __FWCAMP_AUTO_TYPE_NONCOPYABLE(__FWCAMP_NAMESPACE_NAME(desc), __FWCAMP_DECLARE_LOCAL_FUNC_NAME(desc)) 55 #define __FWCAMP__REG_NAME(desc) \ 56 BOOST_PP_CAT(__FWCAMP_FUNC_SUFFIX(desc), Reg) 58 #define __FWCAMP__USEROBJREG(desc) \ 59 ::fwCamp::UserObjectRegistrar < __FWCAMP_NAMESPACE_NAME(desc) > 68 #define fwCampMakeFriendDataMacro(desc) \ 69 friend void ::__FWCAMP_DECLARE_FUNC_NAME(desc)(__FWCAMP_CLASS_BUILDER_TYPE(desc) &builder); \ 73 #define fwCampMakeFriendMacro(desc) \ 74 friend void ::__FWCAMP_DECLARE_FUNC_NAME(desc)(__FWCAMP_CLASS_BUILDER_TYPE(desc) &builder); \ 78 #define fwCampDeclareMacro(classname) \ 79 CAMP_TYPE_NONCOPYABLE(classname) 83 #define fwCampAutoDeclareDataMacro( desc, export) \ 86 template<typename T> \ 87 struct UserObjectRegistrar; \ 89 fwCorePredeclare(desc) \ 90 __FWCAMP__AUTO__DECLARE__MACRO(desc) 94 #define fwCampAutoDeclareMacro( desc, export) \ 95 fwCorePredeclare(desc) \ 96 export __FWCAMP__AUTO__DECLARE__MACRO(desc) 100 #define fwCampAutoDeclareEnumMacro(desc) \ 101 void __FWCAMP_DECLARE_FUNC_NAME(desc)(camp::EnumBuilder &); \ 102 inline void __FWCAMP_DECLARE_LOCAL_FUNC_NAME(desc)() \ 104 camp::EnumBuilder builder = \ 105 camp::Enum::declare< __FWCAMP_NAMESPACE_NAME(desc) >(BOOST_PP_STRINGIZE( __FWCAMP_NAMESPACE_NAME(desc) )); \ 106 __FWCAMP_DECLARE_FUNC_NAME(desc)(builder); \ 108 CAMP_TYPE(__FWCAMP_NAMESPACE_NAME(desc)) 112 #define fwCampImplementMacro(desc) \ 113 void __FWCAMP_DECLARE_FUNC_NAME(desc)(__FWCAMP_CLASS_BUILDER_TYPE(desc) &builder) 117 #define fwCampImplementDataMacro(desc) \ 118 static __FWCAMP__USEROBJREG(desc) __FWCAMP__REG_NAME(desc)(BOOST_PP_STRINGIZE( __FWCAMP_NAMESPACE_NAME(desc) )); \ 119 void __FWCAMP_DECLARE_FUNC_NAME(desc)(__FWCAMP_CLASS_BUILDER_TYPE(desc) &builder) 127 #define fwCampImplementEnumMacro(desc) \ 128 void __FWCAMP_DECLARE_FUNC_NAME(desc)(camp::EnumBuilder& builder) 135 #define fwCampDeclareAccessor(object, attribut) \ 140 class Accessor1< __FWCAMP_NAMESPACE_NAME(object), SPTR( __FWCAMP_NAMESPACE_NAME(attribut) )& > \ 143 typedef SPTR ( __FWCAMP_NAMESPACE_NAME (attribut) )& ReturnType; \ 144 typedef ObjectTraits< SPTR( __FWCAMP_NAMESPACE_NAME(attribut) )& > Traits; \ 145 typedef Traits::DataType DataType; \ 146 typedef __FWCAMP_NAMESPACE_NAME (object) ClassType; \ 154 template <typename F> \ 155 Accessor1(F getter) : \ 160 ReturnHelper< ReturnType>::Type get(ClassType& objectptr) const \ 162 ReturnType ptr = m_getter(objectptr); \ 163 return ReturnHelper< ReturnType>::get(ptr); \ 166 bool set(ClassType& objectptr, const Value &value) const \ 168 ReturnType ptr = m_getter(objectptr); \ 169 ptr = __FWCAMP_NAMESPACE_NAME(attribut) ::dynamicCast(((value.to< DataType* >()))->getSptr()); \ 175 boost::function< ReturnType(ClassType&)> m_getter; \ 183 #endif // __FWCAMP_MACROS_HPP__ This file defines fwCore base macros.