vtk-m2/vtkm/cont/ArrayHandleIndex.h
Kenneth Moreland 7ff62d8d6b Explicitly add destructors and copy constructors to ArrayHandle classes
Under CUDA, the default constructors and destructors created are exported
as __host__ and __device__, which causes problems because they used a boost
pointer that only works on the host. The explicit copy constructors and
destructors do the same thing as the default ones except declared to only
work on the host.
2015-10-21 07:50:52 -06:00

76 lines
2.2 KiB
C++

//=============================================================================
//
// 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.
//
// Copyright 2015 Sandia Corporation.
// Copyright 2015 UT-Battelle, LLC.
// Copyright 2015 Los Alamos National Security.
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//
//=============================================================================
#ifndef vtk_m_cont_ArrayHandleIndex_h
#define vtk_m_cont_ArrayHandleIndex_h
#include <vtkm/cont/ArrayHandleImplicit.h>
namespace vtkm {
namespace cont {
namespace detail {
struct IndexFunctor {
VTKM_EXEC_CONT_EXPORT
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.
///
class ArrayHandleIndex
: public vtkm::cont::ArrayHandleImplicit<vtkm::Id, detail::IndexFunctor>
{
typedef vtkm::cont::ArrayHandleImplicit<vtkm::Id, detail::IndexFunctor>
Superclass;
public:
typedef Superclass::ValueType ValueType;
typedef Superclass::StorageTag StorageTag;
VTKM_CONT_EXPORT
ArrayHandleIndex(vtkm::Id length = 0)
: Superclass(detail::IndexFunctor(), length) { }
VTKM_CONT_EXPORT
ArrayHandleIndex(const ArrayHandleIndex &src)
: Superclass(src)
{ }
VTKM_CONT_EXPORT
ArrayHandleIndex(const vtkm::cont::ArrayHandle<ValueType,StorageTag> &src)
: Superclass(src) { }
VTKM_CONT_EXPORT
virtual ~ArrayHandleIndex() { }
};
}
} // namespace vtkm::cont
#endif //vtk_m_cont_ArrayHandleIndex_h