VTK
9.1.0
|
Dispatch to functor based on two pointer types. More...
#include <vtkDoubleDispatcher.h>
Public Member Functions | |
template<class SomeLhs , class SomeRhs , class Functor > | |
void | Add (Functor fun) |
Add in a functor that is mapped to the combination of the two template parameters passed in. More... | |
template<class SomeLhs , class SomeRhs > | |
bool | Remove () |
Remove a functor that is bound to the given parameter types. More... | |
ReturnType | Go (BaseLhs *lhs, BaseRhs *rhs) |
Given two pointers of objects that derive from the BaseLhs and BaseRhs we find the matching functor that was added, and call it passing along the given parameters. More... | |
Protected Types | |
typedef vtkDispatcherCommon::TypeInfo | TypeInfo |
typedef vtkDoubleDispatcherPrivate::Functor< ReturnType, BaseLhs, BaseRhs > | MappedType |
typedef std::pair< TypeInfo, TypeInfo > | KeyType |
typedef std::map< KeyType, MappedType > | MapType |
Protected Member Functions | |
void | DoAddFunctor (TypeInfo lhs, TypeInfo rhs, MappedType fun) |
bool | DoRemove (TypeInfo lhs, TypeInfo rhs) |
Protected Attributes | |
MapType | FunctorMap |
Dispatch to functor based on two pointer types.
vtkDoubleDispatcher is a class that allows calling a functor based on the derived types of two pointers. 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 when you want to know multiple parameter types, or need to call a specialized implementation for a subset
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 82 of file vtkDoubleDispatcher.h.
|
protected |
Definition at line 136 of file vtkDoubleDispatcher.h.
|
protected |
Definition at line 137 of file vtkDoubleDispatcher.h.
|
protected |
Definition at line 142 of file vtkDoubleDispatcher.h.
|
protected |
Definition at line 143 of file vtkDoubleDispatcher.h.
|
inline |
Add in a functor that is mapped to the combination of the two template parameters passed in.
When instances of the two parameters are passed in on the Go method we will call the functor and pass along the given parameters. Note: This copies the functor so pass stateful functors by pointer.
Definition at line 99 of file vtkDoubleDispatcher.h.
|
inline |
Remove a functor that is bound to the given parameter types.
Will return true if we did remove a functor.
Definition at line 110 of file vtkDoubleDispatcher.h.
ReturnType vtkDoubleDispatcher< BaseLhs, BaseRhs, ReturnType, CastingPolicy >::Go | ( | BaseLhs * | lhs, |
BaseRhs * | rhs | ||
) |
Given two pointers of objects that derive from the BaseLhs and BaseRhs we find the matching functor that was added, and call it passing along the given parameters.
It should be noted that the functor will be called with the parameters being the derived type that Functor was registered with.
Note: This will only find exact matches. So if you add functor to find vtkDataArray,vtkDataArray, it will not be called if passed with vtkDoubleArray,vtkDoubleArray.
Definition at line 210 of file vtkDoubleDispatcher.h.
|
protected |
Definition at line 190 of file vtkDoubleDispatcher.h.
|
protected |
Definition at line 200 of file vtkDoubleDispatcher.h.
|
protected |
Definition at line 144 of file vtkDoubleDispatcher.h.