Commit 46e21d5d authored by Martin Heistermann's avatar Martin Heistermann

Properties: allow access using the correct handle type, deprecate direct size_t indexing

parent 2354de4c
......@@ -48,13 +48,42 @@
namespace OpenVolumeMesh {
// Defines for property handles
class VertexPropHandle : public OpenVolumeMeshHandle { public: explicit VertexPropHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class EdgePropHandle : public OpenVolumeMeshHandle { public: explicit EdgePropHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class HalfEdgePropHandle : public OpenVolumeMeshHandle { public: explicit HalfEdgePropHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class FacePropHandle : public OpenVolumeMeshHandle { public: explicit FacePropHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class HalfFacePropHandle : public OpenVolumeMeshHandle { public: explicit HalfFacePropHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class CellPropHandle : public OpenVolumeMeshHandle { public: explicit CellPropHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class MeshPropHandle : public OpenVolumeMeshHandle { public: explicit MeshPropHandle(int _idx = -1) : OpenVolumeMeshHandle(_idx) {} };
class VertexPropHandle : public OpenVolumeMeshHandle {
public:
using OpenVolumeMeshHandle::OpenVolumeMeshHandle;
using EntityHandleT = VertexHandle;
};
class EdgePropHandle : public OpenVolumeMeshHandle {
public:
using OpenVolumeMeshHandle::OpenVolumeMeshHandle;
using EntityHandleT = EdgeHandle;
};
class HalfEdgePropHandle : public OpenVolumeMeshHandle {
public:
using OpenVolumeMeshHandle::OpenVolumeMeshHandle;
using EntityHandleT = HalfEdgeHandle;
};
class FacePropHandle : public OpenVolumeMeshHandle {
public:
using OpenVolumeMeshHandle::OpenVolumeMeshHandle;
using EntityHandleT = FaceHandle;
};
class HalfFacePropHandle : public OpenVolumeMeshHandle {
public:
using OpenVolumeMeshHandle::OpenVolumeMeshHandle;
using EntityHandleT = HalfFaceHandle;
};
class CellPropHandle : public OpenVolumeMeshHandle {
public:
using OpenVolumeMeshHandle::OpenVolumeMeshHandle;
using EntityHandleT = CellHandle;
};
class MeshPropHandle : public OpenVolumeMeshHandle
{
public:
using OpenVolumeMeshHandle::OpenVolumeMeshHandle;
using EntityHandleT = OpenVolumeMeshHandle;
};
} // Namespace OpenVolumeMesh
......
......@@ -48,6 +48,7 @@
#include "BaseProperty.hh"
#include "OpenVolumeMeshHandle.hh"
#include "../System/MemoryInclude.hh"
#include "../System/Deprecation.hh"
namespace OpenVolumeMesh {
......@@ -73,6 +74,8 @@ public:
typedef typename PropT::reference reference;
typedef typename PropT::const_reference const_reference;
typedef typename HandleT::EntityHandleT EntityHandleT;
/// Constructor
PropertyPtr(PropT* _ptr, ResourceManager& _resMan, HandleT _handle);
......@@ -93,11 +96,13 @@ public:
const_iterator end() const { return ptr::shared_ptr<PropT>::get()->end(); }
iterator end() { return ptr::shared_ptr<PropT>::get()->end(); }
OVM_DEPRECATED("use handles to index properties")
reference operator[](size_t _idx) { return (*ptr::shared_ptr<PropT>::get())[_idx]; }
OVM_DEPRECATED("use handles to index properties")
const_reference operator[](size_t _idx) const { return (*ptr::shared_ptr<PropT>::get())[_idx]; }
reference operator[](const OpenVolumeMeshHandle& _h) { return (*ptr::shared_ptr<PropT>::get())[_h.idx()]; }
const_reference operator[](const OpenVolumeMeshHandle& _h) const { return (*ptr::shared_ptr<PropT>::get())[_h.idx()]; }
reference operator[](const EntityHandleT& _h) { return (*ptr::shared_ptr<PropT>::get())[_h.idx()]; }
const_reference operator[](const EntityHandleT& _h) const { return (*ptr::shared_ptr<PropT>::get())[_h.idx()]; }
virtual OpenVolumeMeshHandle handle() const;
......
#pragma once
#if defined(__cplusplus) && (__cplusplus >= 201402L)
# define OVM_DEPRECATED(msg) [[deprecated(msg)]]
#elif defined(__GNUC__) || defined(__clang__)
# define OVM_DEPRECATED(msg) __attribute__((deprecated))
#elif defined(_MSC_VER)
# define OVM_DEPRECATED(msg) __declspec(deprecated)
#else
# pragma message("WARNING: You need to implement DEPRECATED for this compiler")
# define OVM_DEPRECATED(msg)
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment