Viskores  1.0
CastAndCall.h
Go to the documentation of this file.
1 //============================================================================
2 // The contents of this file are covered by the Viskores license. See
3 // LICENSE.txt for details.
4 //
5 // By contributing to this file, all contributors agree to the Developer
6 // Certificate of Origin Version 1.1 (DCO 1.1) as stated in DCO.txt.
7 //============================================================================
8 
9 //============================================================================
10 // Copyright (c) Kitware, Inc.
11 // All rights reserved.
12 // See LICENSE.txt for details.
13 //
14 // This software is distributed WITHOUT ANY WARRANTY; without even
15 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 // PURPOSE. See the above copyright notice for more information.
17 //============================================================================
18 #ifndef viskores_cont_CastAndCall_h
19 #define viskores_cont_CastAndCall_h
20 
22 
25 
26 #include <utility>
27 
28 namespace viskores
29 {
30 namespace cont
31 {
32 
33 class CoordinateSystem;
34 class Field;
35 
36 template <typename T, typename S>
37 class ArrayHandle;
38 
39 template <viskores::IdComponent>
41 template <typename T>
43 template <typename T, typename S, typename U>
45 template <typename T, typename S>
47 class CellSetExtrude;
48 
49 class UnknownCellSet;
50 
54 template <typename DynamicObject, typename Functor, typename... Args>
55 void CastAndCall(const DynamicObject& dynamicObject, Functor&& f, Args&&... args)
56 {
57  dynamicObject.CastAndCall(std::forward<Functor>(f), std::forward<Args>(args)...);
58 }
59 
62 // actually implemented in viskores/cont/CoordinateSystem.h
63 template <typename Functor, typename... Args>
64 void CastAndCall(const CoordinateSystem& coords, Functor&& f, Args&&... args);
65 
68 // actually implemented in viskores/cont/Field.h
69 template <typename Functor, typename... Args>
70 void CastAndCall(const viskores::cont::Field& field, Functor&& f, Args&&... args);
71 
73 // actually implemented in viskores/cont/UnknownCellSet.h
74 template <typename Functor, typename... Args>
75 void CastAndCall(const viskores::cont::UnknownCellSet& cellSet, Functor&& f, Args&&... args);
76 
80 template <typename T, typename U, typename Functor, typename... Args>
81 void CastAndCall(const viskores::cont::ArrayHandle<T, U>& handle, Functor&& f, Args&&... args)
82 {
83  f(handle, std::forward<Args>(args)...);
84 }
85 
89 // Implemented here to avoid circular dependencies.
90 template <typename Functor, typename... Args>
91 void CastAndCall(const UnknownArrayHandle& handle, Functor&& f, Args&&... args)
92 {
94  std::forward<Functor>(f), std::forward<Args>(args)...);
95 }
96 
100 template <viskores::IdComponent Dim, typename Functor, typename... Args>
101 void CastAndCall(const viskores::cont::CellSetStructured<Dim>& cellset, Functor&& f, Args&&... args)
102 {
103  f(cellset, std::forward<Args>(args)...);
104 }
105 
109 template <typename ConnectivityStorageTag, typename Functor, typename... Args>
111  Functor&& f,
112  Args&&... args)
113 {
114  f(cellset, std::forward<Args>(args)...);
115 }
116 
120 template <typename T, typename S, typename U, typename Functor, typename... Args>
122  Functor&& f,
123  Args&&... args)
124 {
125  f(cellset, std::forward<Args>(args)...);
126 }
127 
131 template <typename PermutationType, typename CellSetType, typename Functor, typename... Args>
133  Functor&& f,
134  Args&&... args)
135 {
136  f(cellset, std::forward<Args>(args)...);
137 }
138 
142 template <typename Functor, typename... Args>
143 void CastAndCall(const viskores::cont::CellSetExtrude& cellset, Functor&& f, Args&&... args)
144 {
145  f(cellset, std::forward<Args>(args)...);
146 }
147 
149 template <typename... Args>
150 void ConditionalCastAndCall(std::true_type, Args&&... args)
151 {
152  viskores::cont::CastAndCall(std::forward<Args>(args)...);
153 }
154 
156 template <typename... Args>
157 void ConditionalCastAndCall(std::false_type, Args&&...)
158 {
159 }
160 
161 namespace internal
162 {
167 struct DynamicTransformTagCastAndCall
168 {
169 };
170 
174 struct DynamicTransformTagStatic
175 {
176 };
177 
186 template <typename T>
187 struct DynamicTransformTraits
188 {
195  using DynamicTag = viskores::cont::internal::DynamicTransformTagStatic;
196 };
197 
198 // Implemented here to avoid circular dependencies.
199 template <>
200 struct DynamicTransformTraits<viskores::cont::UnknownArrayHandle>
201 {
202  using DynamicTag = viskores::cont::internal::DynamicTransformTagCastAndCall;
203 };
204 
205 } // namespace internal
206 
207 }
208 } // namespace viskores::cont
209 
210 #endif //viskores_cont_CastAndCall_h
viskores::cont::CastAndCall
void CastAndCall(const DynamicObject &dynamicObject, Functor &&f, Args &&... args)
A Generic interface to CastAndCall.
Definition: CastAndCall.h:55
VISKORES_DEFAULT_TYPE_LIST
#define VISKORES_DEFAULT_TYPE_LIST
Definition: DefaultTypes.h:53
viskores::cont::CellSetPermutation
Rearranges the cells of one cell set to create another cell set.
Definition: CastAndCall.h:46
viskores::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:313
viskores::IdComponent
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
DefaultTypes.h
VISKORES_DEFAULT_STORAGE_LIST
#define VISKORES_DEFAULT_STORAGE_LIST
Definition: DefaultTypes.h:58
UnknownArrayHandle.h
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
viskores::cont::ConditionalCastAndCall
void ConditionalCastAndCall(std::true_type, Args &&... args)
CastAndCall if the condition is true.
Definition: CastAndCall.h:150
viskores::cont::UnknownArrayHandle::CastAndCallForTypes
void CastAndCallForTypes(Functor &&functor, Args &&... args) const
Call a functor using the underlying array type.
Definition: UnknownArrayHandle.h:1211
viskores::cont::CellSetExplicit
Defines an irregular collection of cells.
Definition: CastAndCall.h:44
viskores::cont::CellSetStructured
Defines a 1-, 2-, or 3-dimensional structured grid of points.
Definition: CastAndCall.h:40
viskores::cont::UnknownCellSet
A CellSet of an unknown type.
Definition: UnknownCellSet.h:56
viskores::cont::CellSetSingleType
An explicit cell set with all cells of the same shape.
Definition: CastAndCall.h:42
viskores::cont::UnknownArrayHandle
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:451
viskores::cont::CellSetExtrude
Defines a 3-dimensional extruded mesh representation.
Definition: CellSetExtrude.h:64
viskores::cont::Field
A Field encapsulates an array on some piece of the mesh, such as the points, a cell set,...
Definition: Field.h:39
IndexTag.h