VTK  9.0.20200813
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
68 template <typename T>
69 VTK_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
89 template <class DefaultFunctorType, typename ReturnType = void>
90 VTK_DEPRECATED_IN_9_0_0("Use vtkArrayDispatch")
92 {
93 public:
118  vtkDataArrayDispatcher(DefaultFunctorType& f);
119 
125 
126  virtual ~vtkDataArrayDispatcher();
127 
131  ReturnType Go(vtkDataArray* lhs);
132 
133 protected:
134  DefaultFunctorType* DefaultFunctor;
136 };
137 
138 // We are making all these method non-inline to reduce compile time overhead
139 
140 //----------------------------------------------------------------------------
141 template <class DefaultFunctorType, typename ReturnType>
142 VTK_DEPRECATED_IN_9_0_0("Use vtkArrayDispatch")
143 vtkDataArrayDispatcher<DefaultFunctorType, ReturnType>::vtkDataArrayDispatcher(
144  DefaultFunctorType& fun)
145  : DefaultFunctor(&fun)
146  , OwnsFunctor(false)
147 {
148  VTK_LEGACY_BODY(vtkDataArrayDispatcher, "VTK 9.0");
149 }
150 
151 //----------------------------------------------------------------------------
152 template <class DefaultFunctorType, typename ReturnType>
153 VTK_DEPRECATED_IN_9_0_0("Use vtkArrayDispatch")
154 vtkDataArrayDispatcher<DefaultFunctorType, ReturnType>::vtkDataArrayDispatcher()
155  : DefaultFunctor(new DefaultFunctorType())
156  , OwnsFunctor(true)
157 {
158  VTK_LEGACY_BODY(vtkDataArrayDispatcher, "VTK 9.0");
159 }
160 
161 //----------------------------------------------------------------------------
162 template <class DefaultFunctorType, typename ReturnType>
163 VTK_DEPRECATED_IN_9_0_0("Use vtkArrayDispatch")
164 vtkDataArrayDispatcher<DefaultFunctorType, ReturnType>::~vtkDataArrayDispatcher()
165 {
166  if (OwnsFunctor)
167  {
168  delete this->DefaultFunctor;
169  }
170 }
171 
172 //----------------------------------------------------------------------------
173 template <class DefaultFunctorType, typename ReturnType>
174 VTK_DEPRECATED_IN_9_0_0("Use vtkArrayDispatch")
175 ReturnType 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
vtkIdType
int vtkIdType
Definition: vtkType.h:330
vtkDataArrayDispatcher::OwnsFunctor
bool OwnsFunctor
Definition: vtkDataArrayDispatcher.h:135
vtkDataArrayDispatcherPointer::NumberOfTuples
vtkIdType NumberOfTuples
Definition: vtkDataArrayDispatcher.h:74
vtkDataArrayDispatcher
Dispatch to functor vtkDataArrayType.
Definition: vtkDataArrayDispatcher.h:91
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
vtkDataArrayDispatcherPointer::vtkDataArrayDispatcherPointer
vtkDataArrayDispatcherPointer(vtkDataArray *array)
Definition: vtkDataArrayDispatcher.h:78
vtkType.h
vtkDataArrayDispatcherPointer
Definition: vtkDataArrayDispatcher.h:70
vtkDataArrayDispatcherPointer::ValueType
T ValueType
Definition: vtkDataArrayDispatcher.h:72
VTK_DEPRECATED_IN_9_0_0
#define VTK_DEPRECATED_IN_9_0_0(reason)
Definition: vtkDeprecation.h:83
vtkDataArrayDispatcher::DefaultFunctor
DefaultFunctorType * DefaultFunctor
Definition: vtkDataArrayDispatcher.h:134
vtkDataArray.h
vtkDeprecation.h
vtkDataArrayDispatcherPointer::NumberOfComponents
vtkIdType NumberOfComponents
Definition: vtkDataArrayDispatcher.h:75
vtkDataArrayDispatcherPointer::RawPointer
ValueType * RawPointer
Definition: vtkDataArrayDispatcher.h:76