73 #ifndef vtkDoubleDispatcher_h
74 #define vtkDoubleDispatcher_h
82 class BaseRhs = BaseLhs,
83 typename ReturnType = void,
102 template <
class SomeLhs,
class SomeRhs,
class Functor>
103 void Add(Functor fun) { this->AddInternal<SomeLhs,SomeRhs>(fun, 1); }
109 template <
class SomeLhs,
class SomeRhs>
130 ReturnType
Go(BaseLhs* lhs, BaseRhs* rhs);
141 typedef std::map<KeyType, MappedType >
MapType;
144 template <
class SomeLhs,
class SomeRhs,
class Functor>
145 void AddInternal(
const Functor& fun,
long);
146 template <
class SomeLhs,
class SomeRhs,
class Functor>
147 void AddInternal(Functor* fun,
int);
152 template<
class BaseLhs,
class BaseRhs,
typename ReturnType,
153 template <
class,
class>
class CastingPolicy>
154 template <
class SomeLhs,
class SomeRhs,
class Functor>
162 CastingPolicy<SomeLhs, BaseLhs>,
163 CastingPolicy<SomeRhs, BaseRhs>,
167 DoAddFunctor(
typeid(SomeLhs),
typeid(SomeRhs),mt);
171 template<
class BaseLhs,
class BaseRhs,
typename ReturnType,
172 template <
class,
class>
class CastingPolicy>
173 template <
class SomeLhs,
class SomeRhs,
class Functor>
181 CastingPolicy<SomeLhs, BaseLhs>,
182 CastingPolicy<SomeRhs, BaseRhs>,
186 DoAddFunctor(
typeid(SomeLhs),
typeid(SomeRhs),mt);
190 template<
class BaseLhs,
class BaseRhs,
typename ReturnType,
191 template <
class,
class>
class CastingPolicy>
195 FunctorMap[
KeyType(lhs, rhs)] = fun;
199 template <
class BaseLhs,
class BaseRhs,
typename ReturnType,
200 template <
class,
class>
class CastingPolicy>
204 return FunctorMap.erase(
KeyType(lhs, rhs)) == 1;
208 template <
class BaseLhs,
class BaseRhs,
typename ReturnType,
209 template <
class,
class>
class CastingPolicy>
211 ::Go(BaseLhs* lhs, BaseRhs* rhs)
213 typename MapType::key_type k(
typeid(*lhs),
typeid(*rhs));
214 typename MapType::iterator i = FunctorMap.find(k);
215 if (i == FunctorMap.end())
221 return (i->second)(*lhs,*rhs);
224 #endif // vtkDoubleDispatcher_h