VTK
9.1.0
|
Dispatch to functor based on a pointer type. More...
#include <vtkDispatcher.h>
Public Member Functions | |
template<class SomeLhs , class Functor > | |
void | Add (Functor fun) |
Add in a functor that is mapped to the template SomeLhs parameter. | |
template<class SomeLhs > | |
bool | Remove () |
Remove a functor that is bound to the given parameter type. | |
ReturnType | Go (BaseLhs *lhs) |
Given a pointer to an object that derives from the BaseLhs we find the matching functor that was added, and call it passing along the given parameter. | |
Protected Types | |
typedef vtkDispatcherCommon::TypeInfo | TypeInfo |
typedef vtkDispatcherPrivate::Functor< ReturnType, BaseLhs > | MappedType |
typedef std::map< TypeInfo, MappedType > | MapType |
Protected Member Functions | |
void | DoAddFunctor (TypeInfo lhs, MappedType fun) |
bool | DoRemove (TypeInfo lhs) |
Protected Attributes | |
MapType | FunctorMap |
Dispatch to functor based on a pointer type.
vtkDispatcher is a class that allows calling a functor based on the derived types of a pointer. This form of dynamic dispatching allows the conversion of runtime polymorphism to a compile time polymorphism. For example it can be used as a replacement for the vtkTemplateMacro, with bonus of being easier to understand
Note: By default the return type is void.
The functors that are passed around can contain state, and are allowed to be const or non const. If you are using a functor that does have state, make sure your copy constructor is correct.
Definition at line 88 of file vtkDispatcher.h.
|
protected |
Definition at line 141 of file vtkDispatcher.h.
|
protected |
Definition at line 142 of file vtkDispatcher.h.
|
protected |
Definition at line 146 of file vtkDispatcher.h.
|
inline |
Add in a functor that is mapped to the template SomeLhs parameter.
When instances of the parameter is passed in on the Go method we will call the functor and pass along the given parameter. Note: This copies the functor so pass stateful functors by pointer.
Definition at line 104 of file vtkDispatcher.h.
|
inline |
Remove a functor that is bound to the given parameter type.
Will return true if we did remove a functor.
Definition at line 115 of file vtkDispatcher.h.
ReturnType vtkDispatcher< BaseLhs, ReturnType, CastingPolicy >::Go | ( | BaseLhs * | lhs | ) |
Given a pointer to an object that derives from the BaseLhs we find the matching functor that was added, and call it passing along the given parameter.
It should be noted that the functor will be called with the parameter being the derived type that Functor was registered with.
Note: This will only find exact matches. So if you add functor to find vtkDataArray, it will not be called if passed with a vtkDoubleArray.
Definition at line 204 of file vtkDispatcher.h.
|
protected |
Definition at line 188 of file vtkDispatcher.h.
|
protected |
Definition at line 196 of file vtkDispatcher.h.
|
protected |
Definition at line 147 of file vtkDispatcher.h.