diff --git a/src/OpenVolumeMesh/Core/ForwardDeclarations.hh b/src/OpenVolumeMesh/Core/ForwardDeclarations.hh new file mode 100644 index 0000000000000000000000000000000000000000..5a17c534d740c30730e41ea69885b8adeb94c1cc --- /dev/null +++ b/src/OpenVolumeMesh/Core/ForwardDeclarations.hh @@ -0,0 +1,28 @@ +#pragma once +#include "Entities.hh" + +namespace OpenVolumeMesh { + +class BaseProperty; + +template +class OpenVolumeMeshPropertyT; + +template +class PropHandleT; + +template +class PropertyPtr; + +template +class PropertyTT; + +template using VertexPropertyT = PropertyTT; +template using EdgePropertyT = PropertyTT; +template using HalfEdgePropertyT = PropertyTT; +template using FacePropertyT = PropertyTT; +template using HalfFacePropertyT = PropertyTT; +template using CellPropertyT = PropertyTT; +template using MeshPropertyT = PropertyTT; + +} // namespace OVM diff --git a/src/OpenVolumeMesh/Core/OpenVolumeMeshProperty.hh b/src/OpenVolumeMesh/Core/OpenVolumeMeshProperty.hh index a30b946a07ad6acdd2253e66b3c23f3f2a69e717..9710799996a3b670378a25937e5952045753cc11 100644 --- a/src/OpenVolumeMesh/Core/OpenVolumeMeshProperty.hh +++ b/src/OpenVolumeMesh/Core/OpenVolumeMeshProperty.hh @@ -32,16 +32,7 @@ * * \*===========================================================================*/ -/*===========================================================================*\ - * * - * $Revision$ * - * $Date$ * - * $LastChangedBy$ * - * * -\*===========================================================================*/ - -#ifndef OPENVOLUMEMESHPROPERTY_HH -#define OPENVOLUMEMESHPROPERTY_HH +#pragma once //== INCLUDES ================================================================= @@ -520,6 +511,3 @@ private: } // Namespace OpenVolumeMesh -//============================================================================= -#endif // OPENVOLUMEMESHPROPERTY_HH defined -//============================================================================= diff --git a/src/OpenVolumeMesh/Core/PropertyDefines.cc b/src/OpenVolumeMesh/Core/PropertyDefines.cc index b2667014842c4514c469bab776f073eed200fdfc..24ae408b7e5aa5dc02aacefdf3833de02d75e929 100644 --- a/src/OpenVolumeMesh/Core/PropertyDefines.cc +++ b/src/OpenVolumeMesh/Core/PropertyDefines.cc @@ -53,4 +53,13 @@ template <> const std::string typeName >(){ return "vector_d template <> const std::string typeName >(){ return "vector_vh"; } template <> const std::string typeName >(){ return "vector_hfh"; } template <> const std::string typeName > >(){ return "vector_vector_hfh"; } + +template <> const std::string entityTypeName() { return "VProp"; } +template <> const std::string entityTypeName(){ return "HEProp"; } +template <> const std::string entityTypeName() { return "EProp"; } +template <> const std::string entityTypeName() { return "FProp"; } +template <> const std::string entityTypeName(){ return "HFProp"; } +template <> const std::string entityTypeName() { return "CProp"; } +template <> const std::string entityTypeName() { return "MProp"; } + } // Namespace OpenVolumeMesh diff --git a/src/OpenVolumeMesh/Core/PropertyDefines.hh b/src/OpenVolumeMesh/Core/PropertyDefines.hh index c3155d52b278f4baad65ccd3cd1349d4f0aaa51f..118c813d4725fb7d7557e7f34805052023dc116f 100644 --- a/src/OpenVolumeMesh/Core/PropertyDefines.hh +++ b/src/OpenVolumeMesh/Core/PropertyDefines.hh @@ -39,6 +39,7 @@ #include #include +#include "Entities.hh" #include "PropertyHandles.hh" #include "PropertyPtr.hh" @@ -69,99 +70,41 @@ template <> const std::string typeName >(); template <> const std::string typeName >(); template <> const std::string typeName > >(); -/// Property classes for the different entity types -template -class VertexPropertyT : public PropertyPtr, VertexPropHandle> { -public: - VertexPropertyT(const std::string& _name, ResourceManager& _resMan, VertexPropHandle _handle, const T _def = T()); - virtual ~VertexPropertyT() {} - 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 "VProp"; } - virtual const std::string typeNameWrapper() const { return typeName(); } -private: - VertexPropertyT(OpenVolumeMeshPropertyT *_prop, ResourceManager& _resMan, VertexPropHandle _handle); -}; -template -class EdgePropertyT : public PropertyPtr, EdgePropHandle> { -public: - EdgePropertyT(const std::string& _name, ResourceManager& _resMan, EdgePropHandle _handle, const T _def = T()); - virtual ~EdgePropertyT() {} - 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 "EProp"; } - virtual const std::string typeNameWrapper() const { return typeName(); } -private: - EdgePropertyT(OpenVolumeMeshPropertyT *_prop, ResourceManager& _resMan, EdgePropHandle _handle); -}; -template -class HalfEdgePropertyT : public PropertyPtr, HalfEdgePropHandle> { -public: - HalfEdgePropertyT(const std::string& _name, ResourceManager& _resMan, HalfEdgePropHandle _handle, const T _def = T()); - virtual ~HalfEdgePropertyT() {} - 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 "HEProp"; } - virtual const std::string typeNameWrapper() const { return typeName(); } -private: - HalfEdgePropertyT(OpenVolumeMeshPropertyT *_prop, ResourceManager& _resMan, HalfEdgePropHandle _handle); -}; -template -class FacePropertyT : public PropertyPtr, FacePropHandle> { -public: - FacePropertyT(const std::string& _name, ResourceManager& _resMan, FacePropHandle _handle, const T _def = T()); - virtual ~FacePropertyT() {} - 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 "FProp"; } - virtual const std::string typeNameWrapper() const { return typeName(); } -private: - FacePropertyT(OpenVolumeMeshPropertyT *_prop, ResourceManager& _resMan, FacePropHandle _handle); -}; -template -class HalfFacePropertyT : public PropertyPtr, HalfFacePropHandle> { -public: - HalfFacePropertyT(const std::string& _name, ResourceManager& _resMan, HalfFacePropHandle _handle, const T _def = T()); - virtual ~HalfFacePropertyT() {} - 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 "HFProp"; } - virtual const std::string typeNameWrapper() const { return typeName(); } -private: - HalfFacePropertyT(OpenVolumeMeshPropertyT *_prop, ResourceManager& _resMan, HalfFacePropHandle _handle); -}; -template -class CellPropertyT : public PropertyPtr, CellPropHandle> { -public: - CellPropertyT(const std::string& _name, ResourceManager& _resMan, CellPropHandle _handle, const T _def = T()); - virtual ~CellPropertyT() {} - 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 "CProp"; } - virtual const std::string typeNameWrapper() const { return typeName(); } -private: - CellPropertyT(OpenVolumeMeshPropertyT *_prop, ResourceManager& _resMan, CellPropHandle _handle); -}; -template -class MeshPropertyT : public PropertyPtr, MeshPropHandle> { +template +const std::string entityTypeName(); + +template <> const std::string entityTypeName(); +template <> const std::string entityTypeName(); +template <> const std::string entityTypeName(); +template <> const std::string entityTypeName(); +template <> const std::string entityTypeName(); +template <> const std::string entityTypeName(); +template <> const std::string entityTypeName(); + +template +class PropertyTT : public PropertyPtr, PropHandleT> { public: - MeshPropertyT(const std::string& _name, ResourceManager& _resMan, MeshPropHandle _handle, const T _def = T()); - virtual ~MeshPropertyT() {} + 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 "MProp"; } + virtual const std::string entityType() const { return entityTypeName(); } virtual const std::string typeNameWrapper() const { return typeName(); } private: - MeshPropertyT(OpenVolumeMeshPropertyT *_prop, ResourceManager& _resMan, MeshPropHandle _handle); + PropertyTT(OpenVolumeMeshPropertyT *_prop, ResourceManager& _resMan, PropertyHandleT _handle); }; +template using VertexPropertyT = PropertyTT; +template using EdgePropertyT = PropertyTT; +template using HalfEdgePropertyT = PropertyTT; +template using FacePropertyT = PropertyTT; +template using HalfFacePropertyT = PropertyTT; +template using CellPropertyT = PropertyTT; +template using MeshPropertyT = PropertyTT; + + } // Namespace OpenVolumeMesh #if defined(INCLUDE_TEMPLATES) && !defined(PROPERTYDEFINEST_CC) diff --git a/src/OpenVolumeMesh/Core/PropertyDefinesT_impl.hh b/src/OpenVolumeMesh/Core/PropertyDefinesT_impl.hh index 351c78ab66a981e4c198ca9190629a06b50d44ee..74fa17271f2de60776d50f7c681172f1fc471f8e 100644 --- a/src/OpenVolumeMesh/Core/PropertyDefinesT_impl.hh +++ b/src/OpenVolumeMesh/Core/PropertyDefinesT_impl.hh @@ -49,205 +49,36 @@ namespace OpenVolumeMesh { -/// Property classes for the different entity types -template -VertexPropertyT::VertexPropertyT(const std::string& _name, ResourceManager& _resMan, VertexPropHandle _handle, const T _def) : - PropertyPtr, VertexPropHandle>(new OpenVolumeMeshPropertyT(_name, _def), _resMan, _handle) { +template +PropertyTT::PropertyTT(const std::string& _name, ResourceManager& _resMan, PropertyHandleT _handle, const T _def) : + PropertyPtr, PropertyHandleT>(new OpenVolumeMeshPropertyT(_name, _def), _resMan, _handle) { } -template -VertexPropertyT::VertexPropertyT(OpenVolumeMeshPropertyT *_prop, ResourceManager &_resMan, VertexPropHandle _handle) : - PropertyPtr, VertexPropHandle>(_prop, _resMan, _handle) +template +PropertyTT::PropertyTT(OpenVolumeMeshPropertyT *_prop, ResourceManager &_resMan, PropertyHandleT _handle) : + PropertyPtr, PropertyHandleT>(_prop, _resMan, _handle) { } -template -BaseProperty *VertexPropertyT::clone(ResourceManager &_resMan, OpenVolumeMeshHandle _handle) const +template +BaseProperty *PropertyTT::clone(ResourceManager &_resMan, OpenVolumeMeshHandle _handle) const { auto prop_clone = ptr::shared_ptr>::get()->clone(); - return new VertexPropertyT(prop_clone, _resMan, VertexPropHandle(_handle.idx())); + return new PropertyTT(prop_clone, _resMan, PropertyHandleT(_handle.idx())); } -template -void VertexPropertyT::serialize(std::ostream& _ostr) const { - PropertyPtr, VertexPropHandle>::get()->serialize(_ostr); +template +void PropertyTT::serialize(std::ostream& _ostr) const { + PropertyPtr, PropertyHandleT>::get()->serialize(_ostr); } -template -void VertexPropertyT::deserialize(std::istream& _istr) { - PropertyPtr, VertexPropHandle>::get()->deserialize(_istr); +template +void PropertyTT::deserialize(std::istream& _istr) { + PropertyPtr, PropertyHandleT>::get()->deserialize(_istr); } -template -EdgePropertyT::EdgePropertyT(const std::string& _name, ResourceManager& _resMan, EdgePropHandle _handle, const T _def) : - PropertyPtr, EdgePropHandle>(new OpenVolumeMeshPropertyT(_name, _def), _resMan, _handle) { - -} -template -EdgePropertyT::EdgePropertyT(OpenVolumeMeshPropertyT *_prop, ResourceManager &_resMan, EdgePropHandle _handle) : - PropertyPtr, EdgePropHandle>(_prop, _resMan, _handle) -{ -} - -template -BaseProperty *EdgePropertyT::clone(ResourceManager &_resMan, const OpenVolumeMeshHandle _handle) const -{ - auto prop_clone = ptr::shared_ptr>::get()->clone(); - return new EdgePropertyT(prop_clone, _resMan, EdgePropHandle(_handle.idx())); -} - -template -void EdgePropertyT::serialize(std::ostream& _ostr) const { - PropertyPtr, EdgePropHandle>::get()->serialize(_ostr); -} - -template -void EdgePropertyT::deserialize(std::istream& _istr) { - PropertyPtr, EdgePropHandle>::get()->deserialize(_istr); -} - -template -HalfEdgePropertyT::HalfEdgePropertyT(const std::string& _name, ResourceManager& _resMan, HalfEdgePropHandle _handle, const T _def) : - PropertyPtr, HalfEdgePropHandle>(new OpenVolumeMeshPropertyT(_name, _def), _resMan, _handle) { - -} -template -HalfEdgePropertyT::HalfEdgePropertyT(OpenVolumeMeshPropertyT *_prop, ResourceManager &_resMan, HalfEdgePropHandle _handle) : - PropertyPtr, HalfEdgePropHandle>(_prop, _resMan, _handle) -{ -} - -template -BaseProperty *HalfEdgePropertyT::clone(ResourceManager &_resMan, const OpenVolumeMeshHandle _handle) const -{ - auto prop_clone = ptr::shared_ptr>::get()->clone(); - return new HalfEdgePropertyT(prop_clone, _resMan, HalfEdgePropHandle(_handle.idx())); -} - -template -void HalfEdgePropertyT::serialize(std::ostream& _ostr) const { - PropertyPtr, HalfEdgePropHandle>::get()->serialize(_ostr); -} - -template -void HalfEdgePropertyT::deserialize(std::istream& _istr) { - PropertyPtr, HalfEdgePropHandle>::get()->deserialize(_istr); -} - -template -FacePropertyT::FacePropertyT(const std::string& _name, ResourceManager& _resMan, FacePropHandle _handle, const T _def) : - PropertyPtr, FacePropHandle>(new OpenVolumeMeshPropertyT(_name, _def), _resMan, _handle) { - -} -template -FacePropertyT::FacePropertyT(OpenVolumeMeshPropertyT *_prop, ResourceManager &_resMan, FacePropHandle _handle) : - PropertyPtr, FacePropHandle>(_prop, _resMan, _handle) -{ -} - -template -BaseProperty *FacePropertyT::clone(ResourceManager &_resMan, const OpenVolumeMeshHandle _handle) const -{ - auto prop_clone = ptr::shared_ptr>::get()->clone(); - return new FacePropertyT(prop_clone, _resMan, FacePropHandle(_handle.idx())); -} - -template -void FacePropertyT::serialize(std::ostream& _ostr) const { - PropertyPtr, FacePropHandle>::get()->serialize(_ostr); -} - -template -void FacePropertyT::deserialize(std::istream& _istr) { - PropertyPtr, FacePropHandle>::get()->deserialize(_istr); -} - -template -HalfFacePropertyT::HalfFacePropertyT(const std::string& _name, ResourceManager& _resMan, HalfFacePropHandle _handle, const T _def) : - PropertyPtr, HalfFacePropHandle>(new OpenVolumeMeshPropertyT(_name, _def), _resMan, _handle) { - -} -template -HalfFacePropertyT::HalfFacePropertyT(OpenVolumeMeshPropertyT *_prop, ResourceManager &_resMan, HalfFacePropHandle _handle) : - PropertyPtr, HalfFacePropHandle>(_prop, _resMan, _handle) -{ -} - -template -BaseProperty *HalfFacePropertyT::clone(ResourceManager &_resMan, const OpenVolumeMeshHandle _handle) const -{ - auto prop_clone = ptr::shared_ptr>::get()->clone(); - return new HalfFacePropertyT(prop_clone, _resMan, HalfFacePropHandle(_handle.idx())); -} - -template -void HalfFacePropertyT::serialize(std::ostream& _ostr) const { - PropertyPtr, HalfFacePropHandle>::get()->serialize(_ostr); -} - -template -void HalfFacePropertyT::deserialize(std::istream& _istr) { - PropertyPtr, HalfFacePropHandle>::get()->deserialize(_istr); -} - -template -CellPropertyT::CellPropertyT(const std::string& _name, ResourceManager& _resMan, CellPropHandle _handle, const T _def) : - PropertyPtr, CellPropHandle>(new OpenVolumeMeshPropertyT(_name, _def), _resMan, _handle) { - -} -template -CellPropertyT::CellPropertyT(OpenVolumeMeshPropertyT *_prop, ResourceManager &_resMan, CellPropHandle _handle) : - PropertyPtr, CellPropHandle>(_prop, _resMan, _handle) -{ -} - -template -BaseProperty *CellPropertyT::clone(ResourceManager &_resMan, const OpenVolumeMeshHandle _handle) const -{ - auto prop_clone = ptr::shared_ptr>::get()->clone(); - return new CellPropertyT(prop_clone, _resMan, CellPropHandle(_handle.idx())); -} - -template -void CellPropertyT::serialize(std::ostream& _ostr) const { - PropertyPtr, CellPropHandle>::get()->serialize(_ostr); -} - -template -void CellPropertyT::deserialize(std::istream& _istr) { - PropertyPtr, CellPropHandle>::get()->deserialize(_istr); -} - -template -MeshPropertyT::MeshPropertyT(const std::string& _name, ResourceManager& _resMan, MeshPropHandle _handle, const T _def) : - PropertyPtr, MeshPropHandle>(new OpenVolumeMeshPropertyT(_name, _def), _resMan, _handle) { - -} -template -MeshPropertyT::MeshPropertyT(OpenVolumeMeshPropertyT *_prop, ResourceManager &_resMan, MeshPropHandle _handle) : - PropertyPtr, MeshPropHandle>(_prop, _resMan, _handle) -{ -} - -template -BaseProperty *MeshPropertyT::clone(ResourceManager &_resMan, const OpenVolumeMeshHandle _handle) const -{ - auto prop_clone = ptr::shared_ptr>::get()->clone(); - return new MeshPropertyT(prop_clone, _resMan, MeshPropHandle(_handle.idx())); -} - -template -void MeshPropertyT::serialize(std::ostream& _ostr) const { - PropertyPtr, MeshPropHandle>::get()->serialize(_ostr); -} - -template -void MeshPropertyT::deserialize(std::istream& _istr) { - PropertyPtr, MeshPropHandle>::get()->deserialize(_istr); -} - -template +template const std::string typeName() { throw std::runtime_error("Serialization is not supported for these data types!"); } diff --git a/src/OpenVolumeMesh/Core/ResourceManager.hh b/src/OpenVolumeMesh/Core/ResourceManager.hh index 9e671cb590880a12e5442f9aebb3a6d5e0795cc2..35e74d821db9c7c29916f6f15884841e2fea7ae6 100644 --- a/src/OpenVolumeMesh/Core/ResourceManager.hh +++ b/src/OpenVolumeMesh/Core/ResourceManager.hh @@ -32,16 +32,7 @@ * * \*===========================================================================*/ -/*===========================================================================*\ - * * - * $Revision$ * - * $Date$ * - * $LastChangedBy$ * - * * -\*===========================================================================*/ - -#ifndef RESOURCEMANAGER_HH_ -#define RESOURCEMANAGER_HH_ +#pragma once #ifndef NDEBUG #include @@ -51,27 +42,12 @@ #include "OpenVolumeMeshProperty.hh" #include "PropertyHandles.hh" +#include "ForwardDeclarations.hh" namespace OpenVolumeMesh { // Forward declarations class BaseProperty; -template -class VertexPropertyT; -template -class EdgePropertyT; -template -class HalfEdgePropertyT; -template -class FacePropertyT; -template -class HalfFacePropertyT; -template -class CellPropertyT; -template -class MeshPropertyT; -template -class PropertyPtr; class ResourceManager { public: @@ -364,4 +340,3 @@ private: #include "ResourceManagerT_impl.hh" #endif -#endif /* RESOURCEMANAGER_HH_ */