2018-02-21 22:55:02 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2018-02-21 22:55:02 +00:00
|
|
|
// 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.
|
|
|
|
//============================================================================
|
2018-05-10 23:53:39 +00:00
|
|
|
#ifndef vtk_m_cont_ExecutionObjectBase_h
|
|
|
|
#define vtk_m_cont_ExecutionObjectBase_h
|
2018-09-08 17:07:06 +00:00
|
|
|
|
2018-02-21 22:55:02 +00:00
|
|
|
#include <vtkm/Types.h>
|
2018-09-08 17:07:06 +00:00
|
|
|
|
2019-04-17 17:59:49 +00:00
|
|
|
#include <vtkm/cont/serial/internal/DeviceAdapterTagSerial.h>
|
2018-09-08 17:07:06 +00:00
|
|
|
|
2018-02-21 22:55:02 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace cont
|
|
|
|
{
|
2018-09-08 17:07:06 +00:00
|
|
|
|
2018-05-10 23:53:39 +00:00
|
|
|
/// Base \c ExecutionObjectBase for execution objects to inherit from so that
|
2018-02-21 22:55:02 +00:00
|
|
|
/// you can use an arbitrary object as a parameter in an execution environment
|
2018-09-08 17:07:06 +00:00
|
|
|
/// function. Any subclass of \c ExecutionObjectBase must implement a
|
|
|
|
/// \c PrepareForExecution method that takes a device adapter tag and returns
|
|
|
|
/// an object for that device.
|
|
|
|
///
|
|
|
|
struct ExecutionObjectBase
|
|
|
|
{
|
|
|
|
};
|
2018-02-21 22:55:02 +00:00
|
|
|
|
2018-09-08 17:07:06 +00:00
|
|
|
namespace internal
|
2018-02-21 22:55:02 +00:00
|
|
|
{
|
2018-09-08 17:07:06 +00:00
|
|
|
|
|
|
|
namespace detail
|
|
|
|
{
|
|
|
|
|
|
|
|
struct CheckPrepareForExecution
|
|
|
|
{
|
|
|
|
template <typename T>
|
|
|
|
static auto check(T* p)
|
2019-04-09 13:52:53 +00:00
|
|
|
-> decltype(p->PrepareForExecution(vtkm::cont::DeviceAdapterTagSerial{}), std::true_type());
|
2018-09-08 17:07:06 +00:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
static auto check(...) -> std::false_type;
|
2018-02-21 22:55:02 +00:00
|
|
|
};
|
2018-09-08 17:07:06 +00:00
|
|
|
|
|
|
|
} // namespace detail
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
using IsExecutionObjectBase =
|
|
|
|
std::is_base_of<vtkm::cont::ExecutionObjectBase, typename std::decay<T>::type>;
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct HasPrepareForExecution
|
|
|
|
: decltype(detail::CheckPrepareForExecution::check<typename std::decay<T>::type>(nullptr))
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace internal
|
2018-02-21 22:55:02 +00:00
|
|
|
}
|
|
|
|
} // namespace vtkm::cont
|
|
|
|
|
2018-09-08 17:07:06 +00:00
|
|
|
/// Checks that the argument is a proper execution object.
|
|
|
|
///
|
|
|
|
#define VTKM_IS_EXECUTION_OBJECT(execObject) \
|
|
|
|
static_assert(::vtkm::cont::internal::IsExecutionObjectBase<execObject>::value, \
|
|
|
|
"Provided type is not a subclass of vtkm::cont::ExecutionObjectBase."); \
|
|
|
|
static_assert(::vtkm::cont::internal::HasPrepareForExecution<execObject>::value, \
|
|
|
|
"Provided type does not have requisite PrepareForExecution method.")
|
|
|
|
|
2018-05-10 23:53:39 +00:00
|
|
|
#endif //vtk_m_cont_ExecutionObjectBase_h
|