mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Provided vtkm::cont::Storage with move schematics
This commit is contained in:
parent
1f86878f78
commit
c66a6e480d
@ -122,6 +122,11 @@ public:
|
||||
///
|
||||
using PortalConstType = ::vtkm::cont::internal::ArrayPortalFromIterators<const ValueType*>;
|
||||
|
||||
VTKM_CONT Storage(const Storage& src);
|
||||
VTKM_CONT Storage(Storage&& src) noexcept;
|
||||
VTKM_CONT Storage& operator=(const Storage& src);
|
||||
VTKM_CONT Storage& operator=(Storage&& src);
|
||||
|
||||
/// Returns a portal to the array.
|
||||
///
|
||||
VTKM_CONT
|
||||
|
@ -118,11 +118,11 @@ StorageBasicBase::~StorageBasicBase()
|
||||
this->ReleaseResources();
|
||||
}
|
||||
|
||||
StorageBasicBase::StorageBasicBase(StorageBasicBase&& src)
|
||||
: Array(src.Array)
|
||||
, AllocatedByteSize(src.AllocatedByteSize)
|
||||
, NumberOfValues(src.NumberOfValues)
|
||||
, DeleteFunction(src.DeleteFunction)
|
||||
StorageBasicBase::StorageBasicBase(StorageBasicBase&& src) noexcept
|
||||
: Array(src.Array),
|
||||
AllocatedByteSize(src.AllocatedByteSize),
|
||||
NumberOfValues(src.NumberOfValues),
|
||||
DeleteFunction(src.DeleteFunction)
|
||||
|
||||
{
|
||||
src.Array = nullptr;
|
||||
@ -146,7 +146,7 @@ StorageBasicBase::StorageBasicBase(const StorageBasicBase& src)
|
||||
}
|
||||
}
|
||||
|
||||
StorageBasicBase StorageBasicBase::operator=(StorageBasicBase&& src)
|
||||
StorageBasicBase& StorageBasicBase::operator=(StorageBasicBase&& src) noexcept
|
||||
{
|
||||
this->ReleaseResources();
|
||||
this->Array = src.Array;
|
||||
@ -161,7 +161,7 @@ StorageBasicBase StorageBasicBase::operator=(StorageBasicBase&& src)
|
||||
return *this;
|
||||
}
|
||||
|
||||
StorageBasicBase StorageBasicBase::operator=(const StorageBasicBase& src)
|
||||
StorageBasicBase& StorageBasicBase::operator=(const StorageBasicBase& src)
|
||||
{
|
||||
if (src.DeleteFunction)
|
||||
{
|
||||
|
@ -83,10 +83,10 @@ public:
|
||||
|
||||
VTKM_CONT ~StorageBasicBase();
|
||||
|
||||
VTKM_CONT StorageBasicBase(StorageBasicBase&& src);
|
||||
VTKM_CONT StorageBasicBase(StorageBasicBase&& src) noexcept;
|
||||
VTKM_CONT StorageBasicBase(const StorageBasicBase& src);
|
||||
VTKM_CONT StorageBasicBase operator=(StorageBasicBase&& src);
|
||||
VTKM_CONT StorageBasicBase operator=(const StorageBasicBase& src);
|
||||
VTKM_CONT StorageBasicBase& operator=(StorageBasicBase&& src) noexcept;
|
||||
VTKM_CONT StorageBasicBase& operator=(const StorageBasicBase& src);
|
||||
|
||||
/// \brief Return the number of bytes allocated for this storage object(Capacity).
|
||||
///
|
||||
@ -178,6 +178,8 @@ public:
|
||||
public:
|
||||
/// \brief construct storage that VTK-m is responsible for
|
||||
VTKM_CONT Storage();
|
||||
VTKM_CONT Storage(const Storage<ValueT, vtkm::cont::StorageTagBasic>& src);
|
||||
VTKM_CONT Storage(Storage<ValueT, vtkm::cont::StorageTagBasic>&& src) noexcept;
|
||||
|
||||
/// \brief construct storage that VTK-m is not responsible for
|
||||
VTKM_CONT Storage(const ValueType* array, vtkm::Id numberOfValues);
|
||||
@ -186,6 +188,9 @@ public:
|
||||
/// responsible for
|
||||
VTKM_CONT Storage(const ValueType* array, vtkm::Id numberOfValues, void (*deleteFunction)(void*));
|
||||
|
||||
VTKM_CONT Storage& operator=(const Storage<ValueT, vtkm::cont::StorageTagBasic>& src);
|
||||
VTKM_CONT Storage& operator=(Storage<ValueT, vtkm::cont::StorageTagBasic>&& src);
|
||||
|
||||
VTKM_CONT void Allocate(vtkm::Id numberOfValues);
|
||||
|
||||
VTKM_CONT PortalType GetPortal();
|
||||
|
@ -29,12 +29,25 @@ namespace cont
|
||||
namespace internal
|
||||
{
|
||||
|
||||
|
||||
template <typename T>
|
||||
Storage<T, vtkm::cont::StorageTagBasic>::Storage()
|
||||
: StorageBasicBase()
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Storage<T, vtkm::cont::StorageTagBasic>::Storage(const Storage<T, vtkm::cont::StorageTagBasic>& src)
|
||||
: StorageBasicBase(src)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Storage<T, vtkm::cont::StorageTagBasic>::Storage(
|
||||
Storage<T, vtkm::cont::StorageTagBasic>&& src) noexcept : StorageBasicBase(std::move(src))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Storage<T, vtkm::cont::StorageTagBasic>::Storage(const T* array, vtkm::Id numberOfValues)
|
||||
: StorageBasicBase(const_cast<T*>(array), numberOfValues, sizeof(T))
|
||||
@ -49,6 +62,22 @@ Storage<T, vtkm::cont::StorageTagBasic>::Storage(const T* array,
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Storage<T, vtkm::cont::StorageTagBasic>& Storage<T, vtkm::cont::StorageTagBasic>::Storage::
|
||||
operator=(const Storage<T, vtkm::cont::StorageTagBasic>& src)
|
||||
{
|
||||
return static_cast<Storage<T, vtkm::cont::StorageTagBasic>&>(StorageBasicBase::operator=(src));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Storage<T, vtkm::cont::StorageTagBasic>& Storage<T, vtkm::cont::StorageTagBasic>::Storage::
|
||||
operator=(Storage<T, vtkm::cont::StorageTagBasic>&& src)
|
||||
{
|
||||
return static_cast<Storage<T, vtkm::cont::StorageTagBasic>&>(
|
||||
StorageBasicBase::operator=(std::move(src)));
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
void Storage<T, vtkm::cont::StorageTagBasic>::Allocate(vtkm::Id numberOfValues)
|
||||
{
|
||||
|
@ -55,6 +55,9 @@ namespace internal
|
||||
template <class ArrayPortalType>
|
||||
class Storage<typename ArrayPortalType::ValueType, StorageTagImplicit<ArrayPortalType>>
|
||||
{
|
||||
using ClassType =
|
||||
Storage<typename ArrayPortalType::ValueType, StorageTagImplicit<ArrayPortalType>>;
|
||||
|
||||
public:
|
||||
using ValueType = typename ArrayPortalType::ValueType;
|
||||
using PortalConstType = ArrayPortalType;
|
||||
@ -74,6 +77,11 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT Storage(const ClassType& src) = default;
|
||||
VTKM_CONT Storage(ClassType&& src) = default;
|
||||
VTKM_CONT ClassType& operator=(const ClassType& src) = default;
|
||||
VTKM_CONT ClassType& operator=(ClassType&& src) = default;
|
||||
|
||||
// All these methods do nothing but raise errors.
|
||||
VTKM_CONT
|
||||
PortalType GetPortal() { throw vtkm::cont::ErrorBadValue("Implicit arrays are read-only."); }
|
||||
|
Loading…
Reference in New Issue
Block a user