76 #ifndef vtkDispatcher_h
77 #define vtkDispatcher_h
88 typename ReturnType = void,
106 template <
class SomeLhs,
class Functor>
107 void Add(Functor fun) { this->AddInternal<SomeLhs>(fun, 1); }
113 template <
class SomeLhs>
134 ReturnType
Go(BaseLhs* lhs);
142 typedef std::map<TypeInfo, MappedType >
MapType;
145 template <
class SomeLhs,
class Functor>
146 void AddInternal(Functor
const& fun,
long);
147 template <
class SomeLhs,
class Functor>
148 void AddInternal(Functor* fun,
int);
153 template<
class BaseLhs,
typename ReturnType,
154 template <
class,
class>
class CastingPolicy>
155 template <
class SomeLhs,
class Functor>
162 CastingPolicy<SomeLhs, BaseLhs>,
166 DoAddFunctor(
typeid(SomeLhs),mt);
171 template<
class BaseLhs,
typename ReturnType,
172 template <
class,
class>
class CastingPolicy>
173 template <
class SomeLhs,
class Functor>
180 CastingPolicy<SomeLhs, BaseLhs>,
184 DoAddFunctor(
typeid(SomeLhs),mt);
188 template<
class BaseLhs,
typename ReturnType,
189 template <
class,
class>
class CastingPolicy>
197 template <
class BaseLhs,
typename ReturnType,
198 template <
class,
class>
class CastingPolicy>
202 return FunctorMap.erase(
TypeInfo(lhs)) == 1;
206 template <
class BaseLhs,
typename ReturnType,
207 template <
class,
class>
class CastingPolicy>
211 typename MapType::key_type k(
typeid(*lhs));
212 typename MapType::iterator i = FunctorMap.find(k);
213 if (i == FunctorMap.end())
218 return (i->second)(*lhs);
221 #endif // vtkDispatcher_h
void Add(Functor fun)
Add in a functor that is mapped to the template SomeLhs parameter.
bool DoRemove(TypeInfo lhs)
vtkDispatcherPrivate::Functor< ReturnType, BaseLhs > MappedType
vtkDispatcherCommon::TypeInfo TypeInfo
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.
std::map< TypeInfo, MappedType > MapType