7 #ifndef __FWTOOLS_DISPATCHER_HPP__ 8 #define __FWTOOLS_DISPATCHER_HPP__ 11 #include <boost/mpl/if.hpp> 12 #include <boost/mpl/empty.hpp> 13 #include <boost/mpl/front.hpp> 14 #include <boost/mpl/pop_front.hpp> 18 #include "fwTools/TypeMapping.hpp" 19 #include "fwTools/Stringizer.hpp" 42 template<
class KeyType>
43 static void invoke(
const KeyType &keytype)
45 std::string msg = ::fwTools::getString(keytype) +
46 " : KeyType value incorrect : no corresponding Type in typelist";
47 throw std::invalid_argument(msg);
51 template<
class KeyType,
class Parameter>
52 static void invoke(
const KeyType &keytype,
const Parameter ¶m )
54 FwCoreNotUsedMacro(param);
55 std::string msg = ::fwTools::getString(keytype) +
56 " : KeyType value incorrect : no corresponding Type in typelist";
57 throw std::invalid_argument(msg);
61 template<
class BaseClass,
class KeyType>
64 std::string msg = ::fwTools::getString(keytype) +
65 " : KeyType value incorrect : no corresponding Type in typelist";
66 throw std::invalid_argument(msg);
84 template<
class TSEQ,
class FUNCTOR >
89 typedef BOOST_DEDUCED_TYPENAME boost::mpl::pop_front<TSEQ>::type Tail;
90 typedef BOOST_DEDUCED_TYPENAME boost::mpl::front<TSEQ>::type Head;
101 namespace mpl = boost::mpl;
106 f.operator()<Head>();
108 f.template operator()<Head>();
113 typedef BOOST_DEDUCED_TYPENAME mpl::if_<
126 template<
class KeyType >
127 static void invoke(
const KeyType &keytype )
129 namespace mpl = boost::mpl;
131 if ( isMapping< Head>(keytype) )
136 f.operator()<Head>();
138 f.template operator()<Head>();
144 typedef BOOST_DEDUCED_TYPENAME mpl::if_<
149 typex::invoke(keytype);
161 template<
class KeyType,
class Parameter >
162 static void invoke(
const KeyType &keytype, Parameter ¶m )
164 namespace mpl = boost::mpl;
166 if ( isMapping< Head>(keytype) )
171 f.operator()<Head>(param);
173 f.template operator()<Head>(param);
180 typedef BOOST_DEDUCED_TYPENAME mpl::if_<
185 typex::invoke(keytype,param);
This file defines fwCore base macros.