Expose storage in ArrayHandle, and Expose data array in StorageBasic.

This commit is contained in:
T.J. Corona 2016-08-02 13:02:11 -04:00
parent 8f406cf460
commit 2ade3ba8d8
2 changed files with 50 additions and 1 deletions

@ -232,10 +232,10 @@ template<
class ArrayHandle : public internal::ArrayHandleBase
{
private:
typedef vtkm::cont::internal::Storage<T,StorageTag_> StorageType;
typedef vtkm::cont::internal::ArrayHandleExecutionManagerBase<T,StorageTag_>
ExecutionManagerType;
public:
typedef vtkm::cont::internal::Storage<T,StorageTag_> StorageType;
typedef T ValueType;
typedef StorageTag_ StorageTag;
typedef typename StorageType::PortalType PortalControl;
@ -302,6 +302,38 @@ public:
return *this;
}
/// Get the storage.
///
VTKM_CONT_EXPORT StorageType& GetStorage()
{
this->SyncControlArray();
if (this->Internals->ControlArrayValid)
{
return this->Internals->ControlArray;
}
else
{
throw vtkm::cont::ErrorControlInternal(
"ArrayHandle::SyncControlArray did not make control array valid.");
}
}
/// Get the storage.
///
VTKM_CONT_EXPORT const StorageType& GetStorage() const
{
this->SyncControlArray();
if (this->Internals->ControlArrayValid)
{
return this->Internals->ControlArray;
}
else
{
throw vtkm::cont::ErrorControlInternal(
"ArrayHandle::SyncControlArray did not make control array valid.");
}
}
/// Get the array portal of the control array.
///
VTKM_CONT_EXPORT PortalControl GetPortalControl()

@ -322,6 +322,23 @@ public:
return PortalConstType(this->Array, this->Array + this->NumberOfValues);
}
/// \brief Get a pointer to the underlying data structure.
///
/// This method returns the pointer to the array held by this array. The
/// memory associated with this array still belongs to the Storage (i.e.
/// Storage will eventually deallocate the array).
///
VTKM_CONT_EXPORT
ValueType *GetArray()
{
return this->Array;
}
VTKM_CONT_EXPORT
const ValueType *GetArray() const
{
return this->Array;
}
/// \brief Take the reference away from this object.
///
/// This method returns the pointer to the array held by this array. It then