73#ifndef vtkDispatcher_h
74#define vtkDispatcher_h
85template <
class BaseLhs,
typename ReturnType = void,
103 template <
class SomeLhs,
class Functor>
107 this->AddInternal<SomeLhs>(fun, 1);
114 template <
class SomeLhs>
117 return DoRemove(
typeid(SomeLhs));
138 ReturnType Go(BaseLhs* lhs);
146 typedef std::map<TypeInfo, MappedType>
MapType;
150 template <
class SomeLhs,
class Functor>
151 void AddInternal(Functor
const& fun,
long);
152 template <
class SomeLhs,
class Functor>
153 void AddInternal(Functor* fun,
int);
158template <
class BaseLhs,
typename ReturnType,
template <
class,
class>
class CastingPolicy>
159template <
class SomeLhs,
class Functor>
161void
vtkDispatcher<BaseLhs, ReturnType, CastingPolicy>::AddInternal(const Functor& fun,
long)
164 CastingPolicy<SomeLhs, BaseLhs>, Functor>
168 DoAddFunctor(
typeid(SomeLhs), mt);
172template <
class BaseLhs,
typename ReturnType,
template <
class,
class>
class CastingPolicy>
173template <
class SomeLhs,
class Functor>
175void
vtkDispatcher<BaseLhs, ReturnType, CastingPolicy>::AddInternal(Functor* fun,
int)
178 CastingPolicy<SomeLhs, BaseLhs>, Functor>
182 DoAddFunctor(
typeid(SomeLhs), mt);
186template <
class BaseLhs,
typename ReturnType,
template <
class,
class>
class CastingPolicy>
194template <
class BaseLhs,
typename ReturnType,
template <
class,
class>
class CastingPolicy>
198 return FunctorMap.erase(
TypeInfo(lhs)) == 1;
202template <
class BaseLhs,
typename ReturnType,
template <
class,
class>
class CastingPolicy>
204ReturnType
vtkDispatcher<BaseLhs, ReturnType, CastingPolicy>::Go(BaseLhs* lhs)
206 typename MapType::key_type k(
typeid(*lhs));
207 typename MapType::iterator i = FunctorMap.find(k);
208 if (i == FunctorMap.end())
213 return (i->second)(*lhs);
Dispatch to functor based on a pointer type.
bool Remove()
Remove a functor that is bound to the given parameter type.
std::map< TypeInfo, MappedType > MapType
void Add(Functor fun)
Add in a functor that is mapped to the template SomeLhs parameter.
vtkDispatcherCommon::TypeInfo TypeInfo
vtkDispatcherPrivate::Functor< ReturnType, BaseLhs > MappedType
#define VTK_DEPRECATED_IN_9_0_0(reason)