75 #ifndef vtkDispatcher_h
76 #define vtkDispatcher_h
87 typename ReturnType = void,
101 template <
class SomeLhs,
class Functor>
102 void Add(Functor fun) { this->AddInternal<SomeLhs>(fun, 1); }
108 template <
class SomeLhs>
122 ReturnType
Go(BaseLhs* lhs);
130 typedef std::map<TypeInfo, MappedType >
MapType;
133 template <
class SomeLhs,
class Functor>
134 void AddInternal(Functor
const& fun,
long);
135 template <
class SomeLhs,
class Functor>
136 void AddInternal(Functor* fun,
int);
141 template<
class BaseLhs,
typename ReturnType,
142 template <
class,
class>
class CastingPolicy>
143 template <
class SomeLhs,
class Functor>
150 CastingPolicy<SomeLhs, BaseLhs>,
154 DoAddFunctor(
typeid(SomeLhs),mt);
159 template<
class BaseLhs,
typename ReturnType,
160 template <
class,
class>
class CastingPolicy>
161 template <
class SomeLhs,
class Functor>
168 CastingPolicy<SomeLhs, BaseLhs>,
172 DoAddFunctor(
typeid(SomeLhs),mt);
176 template<
class BaseLhs,
typename ReturnType,
177 template <
class,
class>
class CastingPolicy>
185 template <
class BaseLhs,
typename ReturnType,
186 template <
class,
class>
class CastingPolicy>
190 return FunctorMap.erase(
TypeInfo(lhs)) == 1;
194 template <
class BaseLhs,
typename ReturnType,
195 template <
class,
class>
class CastingPolicy>
199 typename MapType::key_type k(
typeid(*lhs));
200 typename MapType::iterator i = FunctorMap.find(k);
201 if (i == FunctorMap.end())
206 return (i->second)(*lhs);
209 #endif // vtkDispatcher_h
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)
std::map< TypeInfo, MappedType > MapType