VTK-m  1.8
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 {
85  handle.CastAndCallForTypes<VTKM_DEFAULT_TYPE_LIST, VTKM_DEFAULT_STORAGE_LIST>(
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::UnknownArrayHandle::CastAndCallForTypes
VTKM_CONT void CastAndCallForTypes(Functor &&functor, Args &&... args) const
Call a functor using the underlying array type.
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:287
vtkm
VTKM_NO_DEPRECATED_VIRTUAL.
Definition: Algorithms.h:18
vtkm::cont::CellSetPermutation
Definition: CastAndCall.h:38
vtkm::IdComponent
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
vtkm::cont::CellSetStructured
Definition: CastAndCall.h:32
vtkm::cont::UnknownArrayHandle
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:397
vtkm::cont::CellSetSingleType
Definition: CastAndCall.h:34
vtkm::cont::UnknownCellSet
A CellSet of an unknown type.
Definition: UnknownCellSet.h:50
vtkm::cont::CellSetExtrude
Definition: CellSetExtrude.h:49
UnknownArrayHandle.h
vtkm::cont::Field
A Field encapsulates an array on some piece of the mesh, such as the points, a cell set,...
Definition: cont/Field.h:31
vtkm::cont::CellSetExplicit
Definition: CastAndCall.h:36
vtkm::cont::ConditionalCastAndCall
void ConditionalCastAndCall(std::true_type, Args &&... args)
CastAndCall if the condition is true.
Definition: CastAndCall.h:140
vtkm::cont::CastAndCall
VTKM_DEPRECATED_SUPPRESS_BEGIN class VTKM_ALWAYS_EXPORT VTKM_DEPRECATED(1.6, "Virtual ArrayHandles are being phased out.") ArrayHandleVirtualCoordinates final void CastAndCall(const vtkm::cont::ArrayHandleVirtualCoordinates &coords, Functor &&f, Args &&... args)
ArrayHandleVirtualCoordinates is a specialization of ArrayHandle.
Definition: ArrayHandleVirtualCoordinates.h:52
IndexTag.h