VTK  9.1.0
vtkDataArrayDispatcher.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkDataArrayDispatcher.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
15
54#ifndef vtkDataArrayDispatcher_h
55#define vtkDataArrayDispatcher_h
56
57#ifndef __VTK_WRAP__
58
59#include "vtkDataArray.h" //required for constructor of the vtkDataArrayFunctor
60#include "vtkDeprecation.h" // for VTK_DEPRECATED_IN_9_0_0
61#include "vtkType.h" //Required for vtkIdType
62#include <map> //Required for the storage of template params to runtime params
63
65// Object that is passed to all functor that are used with this class
66// This allows the user the ability to find info about the size
68template <typename T>
69VTK_DEPRECATED_IN_9_0_0("Use vtkArrayDispatch")
71{
72 typedef T ValueType;
73
77
79 : NumberOfTuples(array->GetNumberOfTuples())
80 , NumberOfComponents(array->GetNumberOfComponents())
81 , RawPointer(static_cast<ValueType*>(array->GetVoidPointer(0)))
82 {
83 }
84};
85
87// class template FunctorDispatcher
89template <class DefaultFunctorType, typename ReturnType = void>
90VTK_DEPRECATED_IN_9_0_0("Use vtkArrayDispatch")
92{
93public:
118 vtkDataArrayDispatcher(DefaultFunctorType& f);
119
125
126 virtual ~vtkDataArrayDispatcher();
127
131 ReturnType Go(vtkDataArray* lhs);
132
133protected:
134 DefaultFunctorType* DefaultFunctor;
136};
137
138// We are making all these method non-inline to reduce compile time overhead
139
140//----------------------------------------------------------------------------
141template <class DefaultFunctorType, typename ReturnType>
142VTK_DEPRECATED_IN_9_0_0("Use vtkArrayDispatch")
143vtkDataArrayDispatcher<DefaultFunctorType, ReturnType>::vtkDataArrayDispatcher(
144 DefaultFunctorType& fun)
145 : DefaultFunctor(&fun)
146 , OwnsFunctor(false)
147{
148 VTK_LEGACY_BODY(vtkDataArrayDispatcher, "VTK 9.0");
149}
150
151//----------------------------------------------------------------------------
152template <class DefaultFunctorType, typename ReturnType>
153VTK_DEPRECATED_IN_9_0_0("Use vtkArrayDispatch")
154vtkDataArrayDispatcher<DefaultFunctorType, ReturnType>::vtkDataArrayDispatcher()
155 : DefaultFunctor(new DefaultFunctorType())
156 , OwnsFunctor(true)
157{
158 VTK_LEGACY_BODY(vtkDataArrayDispatcher, "VTK 9.0");
159}
160
161//----------------------------------------------------------------------------
162template <class DefaultFunctorType, typename ReturnType>
163VTK_DEPRECATED_IN_9_0_0("Use vtkArrayDispatch")
164vtkDataArrayDispatcher<DefaultFunctorType, ReturnType>::~vtkDataArrayDispatcher()
165{
166 if (OwnsFunctor)
167 {
168 delete this->DefaultFunctor;
169 }
170}
171
172//----------------------------------------------------------------------------
173template <class DefaultFunctorType, typename ReturnType>
174VTK_DEPRECATED_IN_9_0_0("Use vtkArrayDispatch")
175ReturnType vtkDataArrayDispatcher<DefaultFunctorType, ReturnType>::Go(vtkDataArray* lhs)
176{
177 switch (lhs->GetDataType())
178 {
179 vtkTemplateMacro(return (*this->DefaultFunctor)(vtkDataArrayDispatcherPointer<VTK_TT>(lhs)));
180 }
181 return ReturnType();
182}
183
184#endif // __VTK_WRAP__
185#endif // vtkDataArrayDispatcher_h
186// VTK-HeaderTest-Exclude: vtkDataArrayDispatcher.h
Dispatch to functor vtkDataArrayType.
DefaultFunctorType * DefaultFunctor
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
vtkDataArrayDispatcherPointer(vtkDataArray *array)
#define VTK_DEPRECATED_IN_9_0_0(reason)
int vtkIdType
Definition: vtkType.h:332