VTK-m  2.2
CastAndCall.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_cont_CastAndCall_h
11 #define vtk_m_cont_CastAndCall_h
12 
13 #include <vtkm/internal/IndexTag.h>
14 
15 #include <vtkm/cont/DefaultTypes.h>
17 
18 #include <utility>
19 
20 namespace vtkm
21 {
22 namespace cont
23 {
24 
25 class CoordinateSystem;
26 class Field;
27 
28 template <typename T, typename S>
29 class ArrayHandle;
30 
31 template <vtkm::IdComponent>
33 template <typename T>
35 template <typename T, typename S, typename U>
37 template <typename T, typename S>
39 class CellSetExtrude;
40 
41 class UnknownCellSet;
42 
46 template <typename DynamicObject, typename Functor, typename... Args>
47 void CastAndCall(const DynamicObject& dynamicObject, Functor&& f, Args&&... args)
48 {
49  dynamicObject.CastAndCall(std::forward<Functor>(f), std::forward<Args>(args)...);
50 }
51 
54 // actually implemented in vtkm/cont/CoordinateSystem.h
55 template <typename Functor, typename... Args>
56 void CastAndCall(const CoordinateSystem& coords, Functor&& f, Args&&... args);
57 
60 // actually implemented in vtkm/cont/Field.h
61 template <typename Functor, typename... Args>
62 void CastAndCall(const vtkm::cont::Field& field, Functor&& f, Args&&... args);
63 
65 // actually implemented in vtkm/cont/UnknownCellSet.h
66 template <typename Functor, typename... Args>
67 void CastAndCall(const vtkm::cont::UnknownCellSet& cellSet, Functor&& f, Args&&... args);
68 
72 template <typename T, typename U, typename Functor, typename... Args>
73 void CastAndCall(const vtkm::cont::ArrayHandle<T, U>& handle, Functor&& f, Args&&... args)
74 {
75  f(handle, std::forward<Args>(args)...);
76 }
77 
81 // Implemented here to avoid circular dependencies.
82 template <typename Functor, typename... Args>
83 void CastAndCall(const UnknownArrayHandle& handle, Functor&& f, Args&&... args)
84 {
86  std::forward<Functor>(f), std::forward<Args>(args)...);
87 }
88 
92 template <vtkm::IdComponent Dim, typename Functor, typename... Args>
93 void CastAndCall(const vtkm::cont::CellSetStructured<Dim>& cellset, Functor&& f, Args&&... args)
94 {
95  f(cellset, std::forward<Args>(args)...);
96 }
97 
101 template <typename ConnectivityStorageTag, typename Functor, typename... Args>
103  Functor&& f,
104  Args&&... args)
105 {
106  f(cellset, std::forward<Args>(args)...);
107 }
108 
112 template <typename T, typename S, typename U, typename Functor, typename... Args>
113 void CastAndCall(const vtkm::cont::CellSetExplicit<T, S, U>& cellset, Functor&& f, Args&&... args)
114 {
115  f(cellset, std::forward<Args>(args)...);
116 }
117 
121 template <typename PermutationType, typename CellSetType, typename Functor, typename... Args>
123  Functor&& f,
124  Args&&... args)
125 {
126  f(cellset, std::forward<Args>(args)...);
127 }
128 
132 template <typename Functor, typename... Args>
133 void CastAndCall(const vtkm::cont::CellSetExtrude& cellset, Functor&& f, Args&&... args)
134 {
135  f(cellset, std::forward<Args>(args)...);
136 }
137 
139 template <typename... Args>
140 void ConditionalCastAndCall(std::true_type, Args&&... args)
141 {
142  vtkm::cont::CastAndCall(std::forward<Args>(args)...);
143 }
144 
146 template <typename... Args>
147 void ConditionalCastAndCall(std::false_type, Args&&...)
148 {
149 }
150 
151 namespace internal
152 {
157 struct DynamicTransformTagCastAndCall
158 {
159 };
160 
164 struct DynamicTransformTagStatic
165 {
166 };
167 
176 template <typename T>
177 struct DynamicTransformTraits
178 {
185  using DynamicTag = vtkm::cont::internal::DynamicTransformTagStatic;
186 };
187 
188 // Implemented here to avoid circular dependencies.
189 template <>
190 struct DynamicTransformTraits<vtkm::cont::UnknownArrayHandle>
191 {
192  using DynamicTag = vtkm::cont::internal::DynamicTransformTagCastAndCall;
193 };
194 
195 } // namespace internal
196 
197 }
198 } // namespace vtkm::cont
199 
200 #endif //vtk_m_cont_CastAndCall_h
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:300
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::cont::CellSetPermutation
Rearranges the cells of one cell set to create another cell set.
Definition: CastAndCall.h:38
vtkm::IdComponent
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
vtkm::cont::CellSetStructured
Defines a 1-, 2-, or 3-dimensional structured grid of points.
Definition: CastAndCall.h:32
vtkm::cont::UnknownArrayHandle
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:430
vtkm::cont::CellSetSingleType
An explicit cell set with all cells of the same shape.
Definition: CastAndCall.h:34
vtkm::cont::UnknownCellSet
A CellSet of an unknown type.
Definition: UnknownCellSet.h:48
DefaultTypes.h
vtkm::cont::CastAndCall
void CastAndCall(const DynamicObject &dynamicObject, Functor &&f, Args &&... args)
A Generic interface to CastAndCall.
Definition: CastAndCall.h:47
vtkm::cont::CellSetExtrude
Defines a 3-dimensional extruded mesh representation.
Definition: CellSetExtrude.h:56
UnknownArrayHandle.h
vtkm::cont::Field
A Field encapsulates an array on some piece of the mesh, such as the points, a cell set,...
Definition: Field.h:31
VTKM_DEFAULT_STORAGE_LIST
#define VTKM_DEFAULT_STORAGE_LIST
Definition: DefaultTypes.h:50
vtkm::cont::UnknownArrayHandle::CastAndCallForTypes
void CastAndCallForTypes(Functor &&functor, Args &&... args) const
Call a functor using the underlying array type.
Definition: UnknownArrayHandle.h:1175
VTKM_DEFAULT_TYPE_LIST
#define VTKM_DEFAULT_TYPE_LIST
Definition: DefaultTypes.h:45
vtkm::cont::CellSetExplicit
Defines an irregular collection of cells.
Definition: CastAndCall.h:36
vtkm::cont::ConditionalCastAndCall
void ConditionalCastAndCall(std::true_type, Args &&... args)
CastAndCall if the condition is true.
Definition: CastAndCall.h:140
IndexTag.h