73 #ifndef vtkDispatcher_h 74 #define vtkDispatcher_h 85 typename ReturnType = void,
103 template <
class SomeLhs,
class Functor>
104 void Add(Functor fun) { this->AddInternal<SomeLhs>(fun, 1); }
110 template <
class SomeLhs>
131 ReturnType
Go(BaseLhs* lhs);
139 typedef std::map<TypeInfo, MappedType >
MapType;
142 template <
class SomeLhs,
class Functor>
143 void AddInternal(Functor
const& fun,
long);
144 template <
class SomeLhs,
class Functor>
145 void AddInternal(Functor* fun,
int);
150 template<
class BaseLhs,
typename ReturnType,
151 template <
class,
class>
class CastingPolicy>
152 template <
class SomeLhs,
class Functor>
159 CastingPolicy<SomeLhs, BaseLhs>,
163 DoAddFunctor(
typeid(SomeLhs),mt);
168 template<
class BaseLhs,
typename ReturnType,
169 template <
class,
class>
class CastingPolicy>
170 template <
class SomeLhs,
class Functor>
177 CastingPolicy<SomeLhs, BaseLhs>,
181 DoAddFunctor(
typeid(SomeLhs),mt);
185 template<
class BaseLhs,
typename ReturnType,
186 template <
class,
class>
class CastingPolicy>
194 template <
class BaseLhs,
typename ReturnType,
195 template <
class,
class>
class CastingPolicy>
199 return FunctorMap.erase(
TypeInfo(lhs)) == 1;
203 template <
class BaseLhs,
typename ReturnType,
204 template <
class,
class>
class CastingPolicy>
208 typename MapType::key_type k(
typeid(*lhs));
209 typename MapType::iterator i = FunctorMap.find(k);
210 if (i == FunctorMap.end())
215 return (i->second)(*lhs);
218 #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