70 #ifndef vtkDoubleDispatcher_h
71 #define vtkDoubleDispatcher_h
79 class BaseRhs = BaseLhs,
80 typename ReturnType = void,
99 template <
class SomeLhs,
class SomeRhs,
class Functor>
100 void Add(Functor fun) { this->AddInternal<SomeLhs,SomeRhs>(fun, 1); }
106 template <
class SomeLhs,
class SomeRhs>
127 ReturnType
Go(BaseLhs* lhs, BaseRhs* rhs);
138 typedef std::map<KeyType, MappedType >
MapType;
141 template <
class SomeLhs,
class SomeRhs,
class Functor>
142 void AddInternal(
const Functor& fun,
long);
143 template <
class SomeLhs,
class SomeRhs,
class Functor>
144 void AddInternal(Functor* fun,
int);
149 template<
class BaseLhs,
class BaseRhs,
typename ReturnType,
150 template <
class,
class>
class CastingPolicy>
151 template <
class SomeLhs,
class SomeRhs,
class Functor>
159 CastingPolicy<SomeLhs, BaseLhs>,
160 CastingPolicy<SomeRhs, BaseRhs>,
164 DoAddFunctor(
typeid(SomeLhs),
typeid(SomeRhs),mt);
168 template<
class BaseLhs,
class BaseRhs,
typename ReturnType,
169 template <
class,
class>
class CastingPolicy>
170 template <
class SomeLhs,
class SomeRhs,
class Functor>
178 CastingPolicy<SomeLhs, BaseLhs>,
179 CastingPolicy<SomeRhs, BaseRhs>,
183 DoAddFunctor(
typeid(SomeLhs),
typeid(SomeRhs),mt);
187 template<
class BaseLhs,
class BaseRhs,
typename ReturnType,
188 template <
class,
class>
class CastingPolicy>
192 FunctorMap[
KeyType(lhs, rhs)] = fun;
196 template <
class BaseLhs,
class BaseRhs,
typename ReturnType,
197 template <
class,
class>
class CastingPolicy>
201 return FunctorMap.erase(
KeyType(lhs, rhs)) == 1;
205 template <
class BaseLhs,
class BaseRhs,
typename ReturnType,
206 template <
class,
class>
class CastingPolicy>
208 ::Go(BaseLhs* lhs, BaseRhs* rhs)
210 typename MapType::key_type k(
typeid(*lhs),
typeid(*rhs));
211 typename MapType::iterator i = FunctorMap.find(k);
212 if (i == FunctorMap.end())
218 return (i->second)(*lhs,*rhs);
221 #endif // vtkDoubleDispatcher_h