70#ifndef vtkDoubleDispatcher_h
71#define vtkDoubleDispatcher_h
79template <
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);
155template <
class BaseLhs,
class BaseRhs,
typename ReturnType,
156 template <
class,
class>
class CastingPolicy>
157template <
class SomeLhs,
class SomeRhs,
class Functor>
160 const Functor& fun,
long)
163 SomeRhs, ReturnType, CastingPolicy<SomeLhs, BaseLhs>, CastingPolicy<SomeRhs, BaseRhs>, Functor>
167 DoAddFunctor(
typeid(SomeLhs),
typeid(SomeRhs), mt);
171template <
class BaseLhs,
class BaseRhs,
typename ReturnType,
172 template <
class,
class>
class CastingPolicy>
173template <
class SomeLhs,
class SomeRhs,
class Functor>
179 ReturnType, CastingPolicy<SomeLhs, BaseLhs>, CastingPolicy<SomeRhs, BaseRhs>, Functor>
183 DoAddFunctor(
typeid(SomeLhs),
typeid(SomeRhs), mt);
187template <
class BaseLhs,
class BaseRhs,
typename ReturnType,
188 template <
class,
class>
class CastingPolicy>
193 FunctorMap[
KeyType(lhs, rhs)] = fun;
197template <
class BaseLhs,
class BaseRhs,
typename ReturnType,
198 template <
class,
class>
class CastingPolicy>
203 return FunctorMap.erase(
KeyType(lhs, rhs)) == 1;
207template <
class BaseLhs,
class BaseRhs,
typename ReturnType,
208 template <
class,
class>
class CastingPolicy>
211 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);
Dispatch to functor based on two pointer types.
std::pair< TypeInfo, TypeInfo > KeyType
vtkDispatcherCommon::TypeInfo TypeInfo
bool Remove()
Remove a functor that is bound to the given parameter types.
void Add(Functor fun)
Add in a functor that is mapped to the combination of the two template parameters passed in.
std::map< KeyType, MappedType > MapType
vtkDoubleDispatcherPrivate::Functor< ReturnType, BaseLhs, BaseRhs > MappedType
#define VTK_DEPRECATED_IN_9_0_0(reason)