VTK  9.1.0
Public Member Functions | Protected Attributes | List of all members
vtkDataArrayDispatcher< DefaultFunctorType, ReturnType > Class Template Reference

Dispatch to functor vtkDataArrayType. More...

#include <vtkDataArrayDispatcher.h>

Public Member Functions

 vtkDataArrayDispatcher (DefaultFunctorType &f)
 Specify the functor that is to be used when dispatching. More...
 
 vtkDataArrayDispatcher ()
 Default constructor which will create an instance of the DefaultFunctorType and use that single instance for all calls. More...
 
virtual ~vtkDataArrayDispatcher ()
 
ReturnType Go (vtkDataArray *lhs)
 Execute the default functor with the passed in vtkDataArray;. More...
 

Protected Attributes

DefaultFunctorType * DefaultFunctor
 
bool OwnsFunctor
 

Detailed Description

template<class DefaultFunctorType, typename ReturnType = void>
class vtkDataArrayDispatcher< DefaultFunctorType, ReturnType >

Dispatch to functor vtkDataArrayType.

Warning
The vtkArrayDispatch utilities should be used instead.

vtkDataArrayDispatcher is a class that allows calling a functor based on the data type of the vtkDataArray subclass. This is a wrapper around the vtkTemplateMacro (VTK_TT) to allow easier implementation and readability, while at the same time the ability to use statefull functors.

Note: By default the return type is void. Note: The functor parameter must be of type vtkDataArrayDispatcherPointer

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.

struct sizeOfFunctor{
template<typename T>
int operator()(const vtkDataArrayDispatcherPointer<T>& t) const
{
}
};
Here is an example of using the dispatcher.
\code
int arrayLength = dispatcher.Go(vtkDataArrayPtr);
Dispatch to functor vtkDataArrayType.
ReturnType Go(vtkDataArray *lhs)
Execute the default functor with the passed in vtkDataArray;.
See also
vtkArrayDispatch

Definition at line 91 of file vtkDataArrayDispatcher.h.

Constructor & Destructor Documentation

◆ vtkDataArrayDispatcher() [1/2]

template<class DefaultFunctorType , typename ReturnType >
vtkDataArrayDispatcher< DefaultFunctorType, ReturnType >::vtkDataArrayDispatcher ( DefaultFunctorType &  f)

Specify the functor that is to be used when dispatching.

This allows you to specify a statefull functor.

struct storeLengthFunctor
{
int length;
storeLengthFunctor() : length(0) {}
template<typename T>
void operator()(vtkDataArrayDispatcherPointer<T> array)
{
}
};
storeLengthFunctor storedLength;
dispatcher.Go(exampleDataArray);
@ length
Definition: vtkX3D.h:399

Definition at line 143 of file vtkDataArrayDispatcher.h.

◆ vtkDataArrayDispatcher() [2/2]

template<class DefaultFunctorType , typename ReturnType >
vtkDataArrayDispatcher< DefaultFunctorType, ReturnType >::vtkDataArrayDispatcher

Default constructor which will create an instance of the DefaultFunctorType and use that single instance for all calls.

Definition at line 154 of file vtkDataArrayDispatcher.h.

◆ ~vtkDataArrayDispatcher()

template<class DefaultFunctorType , typename ReturnType >
vtkDataArrayDispatcher< DefaultFunctorType, ReturnType >::~vtkDataArrayDispatcher
virtual

Definition at line 164 of file vtkDataArrayDispatcher.h.

Member Function Documentation

◆ Go()

template<class DefaultFunctorType , typename ReturnType >
ReturnType vtkDataArrayDispatcher< DefaultFunctorType, ReturnType >::Go ( vtkDataArray lhs)

Execute the default functor with the passed in vtkDataArray;.

Definition at line 175 of file vtkDataArrayDispatcher.h.

Member Data Documentation

◆ DefaultFunctor

template<class DefaultFunctorType , typename ReturnType = void>
DefaultFunctorType* vtkDataArrayDispatcher< DefaultFunctorType, ReturnType >::DefaultFunctor
protected

Definition at line 134 of file vtkDataArrayDispatcher.h.

◆ OwnsFunctor

template<class DefaultFunctorType , typename ReturnType = void>
bool vtkDataArrayDispatcher< DefaultFunctorType, ReturnType >::OwnsFunctor
protected

Definition at line 135 of file vtkDataArrayDispatcher.h.


The documentation for this class was generated from the following file: