73 #ifndef vtkDispatcher_h 74 #define vtkDispatcher_h 76 #include "vtkConfigure.h" 78 #ifndef VTK_LEGACY_REMOVE 86 template <
class BaseLhs,
typename ReturnType = void,
103 template <
class SomeLhs,
class Functor>
107 this->AddInternal<SomeLhs>(fun, 1);
114 template <
class 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);
158 template <
class BaseLhs,
typename ReturnType,
template <
class,
class>
class CastingPolicy>
159 template <
class SomeLhs,
class Functor>
163 CastingPolicy<SomeLhs, BaseLhs>, Functor>
167 DoAddFunctor(
typeid(SomeLhs), mt);
171 template <
class BaseLhs,
typename ReturnType,
template <
class,
class>
class CastingPolicy>
172 template <
class SomeLhs,
class Functor>
176 CastingPolicy<SomeLhs, BaseLhs>, Functor>
180 DoAddFunctor(
typeid(SomeLhs), mt);
184 template <
class BaseLhs,
typename ReturnType,
template <
class,
class>
class CastingPolicy>
191 template <
class BaseLhs,
typename ReturnType,
template <
class,
class>
class CastingPolicy>
194 return FunctorMap.erase(
TypeInfo(lhs)) == 1;
198 template <
class BaseLhs,
typename ReturnType,
template <
class,
class>
class CastingPolicy>
201 typename MapType::key_type k(
typeid(*lhs));
202 typename MapType::iterator i = FunctorMap.find(k);
203 if (i == FunctorMap.end())
208 return (i->second)(*lhs);
213 #endif // vtkDispatcher_h void Add(Functor fun)
Add in a functor that is mapped to the template SomeLhs parameter.
bool DoRemove(TypeInfo lhs)
std::map< TypeInfo, MappedType > MapType
vtkDispatcherCommon::TypeInfo TypeInfo
vtkDispatcherPrivate::Functor< ReturnType, BaseLhs > MappedType
void DoAddFunctor(TypeInfo lhs, MappedType fun)
Dispatch to functor based on a pointer type.
ReturnType Go(BaseLhs *lhs)
Given a pointer to an object that derives from the BaseLhs we find the matching functor that was adde...
bool Remove()
Remove a functor that is bound to the given parameter type.