//============================================================================ // Copyright (c) Kitware, Inc. // All rights reserved. // See LICENSE.txt for details. // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notice for more information. //============================================================================ #ifndef vtk_m_cont_ExecutionAndControlObjectBase_h #define vtk_m_cont_ExecutionAndControlObjectBase_h #include namespace vtkm { namespace cont { /// Base \c ExecutionAndControlObjectBase class. These are objects that behave /// as execution objects but can also be use din the control environment. /// Any subclass of \c ExecutionAndControlObjectBase must implement a /// \c PrepareForExecution method that takes a device adapter tag and returns /// an object for that device as well as a \c PrepareForControl that simply /// returns an object that works in the control environment. /// struct ExecutionAndControlObjectBase : vtkm::cont::ExecutionObjectBase { }; namespace internal { namespace detail { struct CheckPrepareForControl { template static auto check(T* p) -> decltype(p->PrepareForControl(), std::true_type()); template static auto check(...) -> std::false_type; }; } // namespace detail template using IsExecutionAndControlObjectBase = std::is_base_of::type>; template struct HasPrepareForControl : decltype(detail::CheckPrepareForControl::check::type>(nullptr)) { }; } // namespace internal } } // namespace vtkm::cont /// Checks that the argument is a proper execution object. /// #define VTKM_IS_EXECUTION_AND_CONTROL_OBJECT(execObject) \ static_assert(::vtkm::cont::internal::IsExecutionAndControlObjectBase::value, \ "Provided type is not a subclass of vtkm::cont::ExecutionAndControlObjectBase."); \ static_assert(::vtkm::cont::internal::HasPrepareForExecution::value, \ "Provided type does not have requisite PrepareForExecution method."); \ static_assert(::vtkm::cont::internal::HasPrepareForControl::value, \ "Provided type does not have requisite PrepareForControl method.") #endif //vtk_m_cont_ExecutionAndControlObjectBase_h