diff --git a/src/OpenVolumeMesh/Core/ForwardDeclarations.hh b/src/OpenVolumeMesh/Core/ForwardDeclarations.hh index 5a17c534d740c30730e41ea69885b8adeb94c1cc..6b594ce9da90ca3270e0867e5e76879b491ee021 100644 --- a/src/OpenVolumeMesh/Core/ForwardDeclarations.hh +++ b/src/OpenVolumeMesh/Core/ForwardDeclarations.hh @@ -11,7 +11,7 @@ class OpenVolumeMeshPropertyT; template class PropHandleT; -template +template class PropertyPtr; template diff --git a/src/OpenVolumeMesh/Core/PropertyDefines.hh b/src/OpenVolumeMesh/Core/PropertyDefines.hh index 118c813d4725fb7d7557e7f34805052023dc116f..939c9d2e74605edf642b0320bb477c7512a277e0 100644 --- a/src/OpenVolumeMesh/Core/PropertyDefines.hh +++ b/src/OpenVolumeMesh/Core/PropertyDefines.hh @@ -82,14 +82,12 @@ template <> const std::string entityTypeName(); template <> const std::string entityTypeName(); template -class PropertyTT : public PropertyPtr, PropHandleT> { +class PropertyTT : public PropertyPtr, Entity> { public: using PropertyHandleT = OpenVolumeMesh::PropHandleT; PropertyTT(const std::string& _name, ResourceManager& _resMan, PropertyHandleT _handle, const T _def = T()); virtual ~PropertyTT() = default; virtual BaseProperty* clone(ResourceManager &_resMan, OpenVolumeMeshHandle _handle) const; - virtual void serialize(std::ostream& _ostr) const; - virtual void deserialize(std::istream& _istr); virtual const std::string entityType() const { return entityTypeName(); } virtual const std::string typeNameWrapper() const { return typeName(); } private: diff --git a/src/OpenVolumeMesh/Core/PropertyDefinesT_impl.hh b/src/OpenVolumeMesh/Core/PropertyDefinesT_impl.hh index 74fa17271f2de60776d50f7c681172f1fc471f8e..edb35dd73d7123bae87e0de9d42c37cc1668338d 100644 --- a/src/OpenVolumeMesh/Core/PropertyDefinesT_impl.hh +++ b/src/OpenVolumeMesh/Core/PropertyDefinesT_impl.hh @@ -32,14 +32,6 @@ * * \*===========================================================================*/ -/*===========================================================================*\ - * * - * $Revision$ * - * $Date$ * - * $LastChangedBy$ * - * * -\*===========================================================================*/ - #define PROPERTYDEFINEST_CC #include @@ -51,13 +43,13 @@ namespace OpenVolumeMesh { template PropertyTT::PropertyTT(const std::string& _name, ResourceManager& _resMan, PropertyHandleT _handle, const T _def) : - PropertyPtr, PropertyHandleT>(new OpenVolumeMeshPropertyT(_name, _def), _resMan, _handle) { + PropertyPtr, Entity>(new OpenVolumeMeshPropertyT(_name, _def), _resMan, _handle) { } template PropertyTT::PropertyTT(OpenVolumeMeshPropertyT *_prop, ResourceManager &_resMan, PropertyHandleT _handle) : - PropertyPtr, PropertyHandleT>(_prop, _resMan, _handle) + PropertyPtr, Entity>(_prop, _resMan, _handle) { } @@ -68,16 +60,6 @@ BaseProperty *PropertyTT::clone(ResourceManager &_resMan, OpenVolumeMe return new PropertyTT(prop_clone, _resMan, PropertyHandleT(_handle.idx())); } -template -void PropertyTT::serialize(std::ostream& _ostr) const { - PropertyPtr, PropertyHandleT>::get()->serialize(_ostr); -} - -template -void PropertyTT::deserialize(std::istream& _istr) { - PropertyPtr, PropertyHandleT>::get()->deserialize(_istr); -} - template const std::string typeName() { throw std::runtime_error("Serialization is not supported for these data types!"); diff --git a/src/OpenVolumeMesh/Core/PropertyPtr.hh b/src/OpenVolumeMesh/Core/PropertyPtr.hh index 6ceaa9a92131894a5b4c401eb32652e1f0a2c6dc..4d666e608c6ef16256948a4412d1dd95af243130 100644 --- a/src/OpenVolumeMesh/Core/PropertyPtr.hh +++ b/src/OpenVolumeMesh/Core/PropertyPtr.hh @@ -37,6 +37,7 @@ #include +#include "PropertyHandles.hh" #include "BaseProperty.hh" #include "OpenVolumeMeshHandle.hh" #include "../System/MemoryInclude.hh" @@ -54,7 +55,7 @@ class ResourceManager; * as soon as the object is not used anymore. */ -template +template class PropertyPtr : protected ptr::shared_ptr, public BaseProperty { public: @@ -66,10 +67,10 @@ public: typedef typename PropT::reference reference; typedef typename PropT::const_reference const_reference; - typedef OpenVolumeMesh::HandleT EntityHandleT; + using EntityHandleT = HandleT; /// Constructor - PropertyPtr(PropT* _ptr, ResourceManager& _resMan, HandleT _handle); + PropertyPtr(PropT* _ptr, ResourceManager& _resMan, PropHandleT _handle); /// Destructor virtual ~PropertyPtr(); @@ -100,6 +101,9 @@ public: reference operator[](const EntityHandleT& _h) { return (*ptr::shared_ptr::get())[_h.idx()]; } const_reference operator[](const EntityHandleT& _h) const { return (*ptr::shared_ptr::get())[_h.idx()]; } + virtual void serialize(std::ostream& _ostr) const { ptr::shared_ptr::get()->serialize(_ostr); } + virtual void deserialize(std::istream& _istr) { ptr::shared_ptr::get()->deserialize(_istr); } + virtual OpenVolumeMeshHandle handle() const; virtual bool persistent() const { return ptr::shared_ptr::get()->persistent(); } diff --git a/src/OpenVolumeMesh/Core/PropertyPtrT_impl.hh b/src/OpenVolumeMesh/Core/PropertyPtrT_impl.hh index 91de79856e8ecd00a58b6d3b97ee4204cc270d08..e31ff3c0401ffdb51ea27f0b470471635f59d0a9 100644 --- a/src/OpenVolumeMesh/Core/PropertyPtrT_impl.hh +++ b/src/OpenVolumeMesh/Core/PropertyPtrT_impl.hh @@ -40,14 +40,14 @@ namespace OpenVolumeMesh { -template -PropertyPtr::PropertyPtr(PropT* _ptr, ResourceManager& _resMan, HandleT _handle) : +template +PropertyPtr::PropertyPtr(PropT* _ptr, ResourceManager& _resMan, PropHandleT _handle) : ptr::shared_ptr(_ptr), BaseProperty(_resMan) { ptr::shared_ptr::get()->set_handle(_handle); } -template -PropertyPtr::~PropertyPtr() { +template +PropertyPtr::~PropertyPtr() { /* * If use count is 2 and prop is not set persistent, @@ -55,48 +55,48 @@ PropertyPtr::~PropertyPtr() { * only one who stores the property. */ if(!locked() && !persistent() && ptr::shared_ptr::use_count() == 2) { - resMan_.release_property(HandleT(handle().idx())); + resMan_.release_property(PropHandleT(handle().idx())); unlock(); } } -template -void PropertyPtr::resize(size_t _size) { +template +void PropertyPtr::resize(size_t _size) { ptr::shared_ptr::get()->resize(_size); } -template -const std::string& PropertyPtr::name() const { +template +const std::string& PropertyPtr::name() const { return ptr::shared_ptr::get()->name(); } -template -void PropertyPtr::delete_element(size_t _idx) { +template +void PropertyPtr::delete_element(size_t _idx) { ptr::shared_ptr::get()->delete_element(_idx); } -template -void PropertyPtr::swap_elements(size_t _idx0, size_t _idx1) { +template +void PropertyPtr::swap_elements(size_t _idx0, size_t _idx1) { ptr::shared_ptr::get()->swap(_idx0, _idx1); } -template -void PropertyPtr::copy(size_t _src_idx, size_t _dst_idx) { +template +void PropertyPtr::copy(size_t _src_idx, size_t _dst_idx) { ptr::shared_ptr::get()->copy(_src_idx, _dst_idx); } -template -void PropertyPtr::set_handle(const OpenVolumeMeshHandle& _handle) { +template +void PropertyPtr::set_handle(const OpenVolumeMeshHandle& _handle) { return ptr::shared_ptr::get()->set_handle(_handle); } -template -OpenVolumeMeshHandle PropertyPtr::handle() const { +template +OpenVolumeMeshHandle PropertyPtr::handle() const { return ptr::shared_ptr::get()->handle(); } -template -void PropertyPtr::delete_multiple_entries(const std::vector& _tags) { +template +void PropertyPtr::delete_multiple_entries(const std::vector& _tags) { ptr::shared_ptr::get()->delete_multiple_entries(_tags); }