vtk-m/vtkm/cont/ArrayHandleIndex.h

96 lines
2.4 KiB
C
Raw Normal View History

2019-04-15 23:24:21 +00:00
//============================================================================
// 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.
2019-04-15 23:24:21 +00:00
//============================================================================
#ifndef vtk_m_cont_ArrayHandleIndex_h
#define vtk_m_cont_ArrayHandleIndex_h
#include <vtkm/cont/ArrayHandleImplicit.h>
2017-05-18 14:29:41 +00:00
namespace vtkm
{
namespace cont
{
2017-05-18 14:29:41 +00:00
namespace detail
{
2017-05-18 14:29:41 +00:00
struct VTKM_ALWAYS_EXPORT IndexFunctor
{
VTKM_EXEC_CONT
vtkm::Id operator()(vtkm::Id index) const { return index; }
};
} // namespace detail
/// \brief An implicit array handle containing the its own indices.
///
/// \c ArrayHandleIndex is an implicit array handle containing the values
/// 0, 1, 2, 3,... to a specified size. Every value in the array is the same
/// as the index to that value.
///
2017-05-30 15:13:18 +00:00
class ArrayHandleIndex : public vtkm::cont::ArrayHandleImplicit<detail::IndexFunctor>
{
public:
2017-05-18 14:29:41 +00:00
VTKM_ARRAY_HANDLE_SUBCLASS_NT(ArrayHandleIndex,
2017-05-30 15:13:18 +00:00
(vtkm::cont::ArrayHandleImplicit<detail::IndexFunctor>));
VTKM_CONT
ArrayHandleIndex(vtkm::Id length)
2017-05-18 14:29:41 +00:00
: Superclass(detail::IndexFunctor(), length)
{
}
};
}
} // namespace vtkm::cont
2018-06-08 15:56:40 +00:00
//=============================================================================
// Specializations of serialization related classes
/// @cond SERIALIZATION
2018-06-08 15:56:40 +00:00
namespace vtkm
{
namespace cont
{
template <>
struct SerializableTypeString<vtkm::cont::detail::IndexFunctor>
2018-06-08 15:56:40 +00:00
{
static VTKM_CONT const std::string Get() { return "AH_IndexFunctor"; }
};
template <>
struct SerializableTypeString<vtkm::cont::ArrayHandleIndex>
: SerializableTypeString<vtkm::cont::ArrayHandleImplicit<vtkm::cont::detail::IndexFunctor>>
2018-06-08 15:56:40 +00:00
{
};
}
} // vtkm::cont
namespace mangled_diy_namespace
2018-06-08 15:56:40 +00:00
{
template <>
struct Serialization<vtkm::cont::detail::IndexFunctor>
{
static VTKM_CONT void save(BinaryBuffer&, const vtkm::cont::detail::IndexFunctor&) {}
static VTKM_CONT void load(BinaryBuffer&, vtkm::cont::detail::IndexFunctor&) {}
};
template <>
struct Serialization<vtkm::cont::ArrayHandleIndex>
: Serialization<vtkm::cont::ArrayHandleImplicit<vtkm::cont::detail::IndexFunctor>>
{
};
} // diy
/// @endcond SERIALIZATION
2018-06-08 15:56:40 +00:00
#endif //vtk_m_cont_ArrayHandleIndex_h