10 #ifndef vtk_m_vtkm_cont_internal_Buffer_h
11 #define vtk_m_vtkm_cont_internal_Buffer_h
42 std::size_t typeSize);
47 return NumberOfValuesToNumberOfBytes(numValues,
sizeof(T));
63 using DeleterType = void(
void*);
66 void BasicDeleter(
void* mem)
68 T* obj =
reinterpret_cast<T*
>(mem);
72 using CopierType =
void*(
const void*);
74 void* BasicCopier(
const void* mem)
76 return new T(*
reinterpret_cast<const T*
>(mem));
89 class InternalsStruct;
90 std::shared_ptr<InternalsStruct> Internals;
92 friend struct vtkm::cont::internal::detail::BufferHelper;
104 VTKM_CONT Buffer& operator=(
const Buffer& src);
105 VTKM_CONT Buffer& operator=(Buffer&& src) noexcept;
129 VTKM_CONT bool MetaDataIsType(
const std::string& type)
const;
131 const std::string& type,
132 detail::DeleterType* deleter,
133 detail::CopierType copier)
const;
134 VTKM_CONT void* GetMetaData(
const std::string& type)
const;
143 template <
typename MetaDataType>
146 return this->MetaDataIsType(vtkm::cont::TypeToString<MetaDataType>());
158 template <
typename MetaDataType>
159 VTKM_CONT void SetMetaData(
const MetaDataType& metadata)
const
161 MetaDataType* metadataCopy =
new MetaDataType(metadata);
162 this->SetMetaData(metadataCopy,
164 detail::BasicDeleter<MetaDataType>,
165 detail::BasicCopier<MetaDataType>);
178 template <
typename MetaDataType>
179 VTKM_CONT MetaDataType& GetMetaData()
const
181 if (!this->HasMetaData())
183 this->SetMetaData(MetaDataType{});
185 return *
reinterpret_cast<MetaDataType*
>(
186 this->GetMetaData(vtkm::cont::TypeToString<MetaDataType>()));
191 VTKM_CONT bool IsAllocatedOnHost()
const;
262 VTKM_CONT void DeepCopyFrom(
const vtkm::cont::internal::Buffer& source)
const;
263 VTKM_CONT void DeepCopyFrom(
const vtkm::cont::internal::Buffer& source,
276 VTKM_CONT void Reset(
const vtkm::cont::internal::BufferInfo& buffer);
288 VTKM_CONT void ReleaseDeviceResources()
const;
292 VTKM_CONT vtkm::cont::internal::BufferInfo GetHostBufferInfo()
const;
299 VTKM_CONT vtkm::cont::internal::BufferInfo GetDeviceBufferInfo(
305 VTKM_CONT vtkm::cont::internal::TransferredBuffer TakeHostBufferOwnership()
const;
310 VTKM_CONT vtkm::cont::internal::TransferredBuffer TakeDeviceBufferOwnership(
330 return (this->Internals == rhs.Internals);
335 return (this->Internals != rhs.Internals);
339 template <
typename... ResetArgs>
340 VTKM_CONT vtkm::cont::internal::Buffer MakeBuffer(ResetArgs&&... resetArgs)
342 vtkm::cont::internal::Buffer buffer;
343 buffer.Reset(vtkm::cont::internal::BufferInfo(std::forward<ResetArgs>(resetArgs)...));
359 static VTKM_CONT void save(BinaryBuffer& bb,
const vtkm::cont::internal::Buffer& obj);
360 static VTKM_CONT void load(BinaryBuffer& bb, vtkm::cont::internal::Buffer& obj);
366 #endif //vtk_m_vtkm_cont_internal_Buffer_h