70 #ifndef vtkDoubleDispatcher_h
71 #define vtkDoubleDispatcher_h
73 #include "vtkConfigure.h"
75 #ifndef VTK_LEGACY_REMOVE
80 template <
class BaseLhs,
class BaseRhs = BaseLhs,
typename ReturnType = void,
98 template <
class SomeLhs,
class SomeRhs,
class Functor>
102 this->AddInternal<SomeLhs, SomeRhs>(fun, 1);
109 template <
class SomeLhs,
class SomeRhs>
112 return DoRemove(
typeid(SomeLhs),
typeid(SomeRhs));
133 ReturnType
Go(BaseLhs* lhs, BaseRhs* rhs);
142 typedef std::pair<TypeInfo, TypeInfo>
KeyType;
143 typedef std::map<KeyType, MappedType>
MapType;
147 template <
class SomeLhs,
class SomeRhs,
class Functor>
148 void AddInternal(
const Functor& fun,
long);
149 template <
class SomeLhs,
class SomeRhs,
class Functor>
150 void AddInternal(Functor* fun,
int);
155 template <
class BaseLhs,
class BaseRhs,
typename ReturnType,
156 template <
class,
class>
class CastingPolicy>
157 template <
class SomeLhs,
class SomeRhs,
class Functor>
159 const Functor& fun,
long)
162 SomeRhs, ReturnType, CastingPolicy<SomeLhs, BaseLhs>, CastingPolicy<SomeRhs, BaseRhs>, Functor>
166 DoAddFunctor(
typeid(SomeLhs),
typeid(SomeRhs), mt);
170 template <
class BaseLhs,
class BaseRhs,
typename ReturnType,
171 template <
class,
class>
class CastingPolicy>
172 template <
class SomeLhs,
class SomeRhs,
class Functor>
177 ReturnType, CastingPolicy<SomeLhs, BaseLhs>, CastingPolicy<SomeRhs, BaseRhs>, Functor>
181 DoAddFunctor(
typeid(SomeLhs),
typeid(SomeRhs), mt);
185 template <
class BaseLhs,
class BaseRhs,
typename ReturnType,
186 template <
class,
class>
class CastingPolicy>
190 FunctorMap[
KeyType(lhs, rhs)] = fun;
194 template <
class BaseLhs,
class BaseRhs,
typename ReturnType,
195 template <
class,
class>
class CastingPolicy>
199 return FunctorMap.erase(
KeyType(lhs, rhs)) == 1;
203 template <
class BaseLhs,
class BaseRhs,
typename ReturnType,
204 template <
class,
class>
class CastingPolicy>
206 BaseLhs* lhs, BaseRhs* rhs)
208 typename MapType::key_type k(
typeid(*lhs),
typeid(*rhs));
209 typename MapType::iterator i = FunctorMap.find(k);
210 if (i == FunctorMap.end())
216 return (i->second)(*lhs, *rhs);
220 #endif // vtkDoubleDispatcher_h