VTK-m  2.2
ExecutionAndControlObjectBase.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_ExecutionAndControlObjectBase_h
11 #define vtk_m_cont_ExecutionAndControlObjectBase_h
12 
14 
15 namespace vtkm
16 {
17 namespace cont
18 {
19 
29 {
30 };
31 
32 namespace internal
33 {
34 
35 namespace detail
36 {
37 
38 struct CheckPrepareForControl
39 {
40  template <typename T>
41  static auto check(T* p) -> decltype(p->PrepareForControl(), std::true_type());
42 
43  template <typename T>
44  static auto check(...) -> std::false_type;
45 };
46 
47 } // namespace detail
48 
49 template <typename T>
50 using IsExecutionAndControlObjectBase =
51  std::is_base_of<vtkm::cont::ExecutionAndControlObjectBase, typename std::decay<T>::type>;
52 
53 template <typename T>
54 struct HasPrepareForControl
55  : decltype(detail::CheckPrepareForControl::check<typename std::decay<T>::type>(nullptr))
56 {
57 };
58 
61 #define VTKM_IS_EXECUTION_AND_CONTROL_OBJECT(execObject) \
62  static_assert(::vtkm::cont::internal::IsExecutionAndControlObjectBase<execObject>::value, \
63  "Provided type is not a subclass of vtkm::cont::ExecutionAndControlObjectBase."); \
64  static_assert(::vtkm::cont::internal::HasPrepareForExecution<execObject>::value, \
65  "Provided type does not have requisite PrepareForExecution method."); \
66  static_assert(::vtkm::cont::internal::HasPrepareForControl<execObject>::value, \
67  "Provided type does not have requisite PrepareForControl method.")
68 
76 template <typename T>
77 VTKM_CONT auto CallPrepareForControl(T&& execObject) -> decltype(execObject.PrepareForControl())
78 {
80 
81  return execObject.PrepareForControl();
82 }
83 
92 template <typename ExecutionAndControlObject>
93 using ControlObjectType =
94  decltype(CallPrepareForControl(std::declval<ExecutionAndControlObject>()));
95 
96 } // namespace internal
97 }
98 } // namespace vtkm::cont
99 
100 #endif //vtk_m_cont_ExecutionAndControlObjectBase_h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::cont::ExecutionAndControlObjectBase
Base ExecutionAndControlObjectBase class.
Definition: ExecutionAndControlObjectBase.h:28
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::cont::ExecutionObjectBase
Base ExecutionObjectBase for execution objects to inherit from so that you can use an arbitrary objec...
Definition: ExecutionObjectBase.h:31
VTKM_IS_EXECUTION_AND_CONTROL_OBJECT
#define VTKM_IS_EXECUTION_AND_CONTROL_OBJECT(execObject)
Checks that the argument is a proper execution object.
Definition: ExecutionAndControlObjectBase.h:61
ExecutionObjectBase.h