Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
PropertyPtr.hh
1 /*===========================================================================*\
2 * *
3 * OpenVolumeMesh *
4 * Copyright (C) 2011 by Computer Graphics Group, RWTH Aachen *
5 * www.openvolumemesh.org *
6 * *
7 *---------------------------------------------------------------------------*
8 * This file is part of OpenVolumeMesh. *
9 * *
10 * OpenVolumeMesh is free software: you can redistribute it and/or modify *
11 * it under the terms of the GNU Lesser General Public License as *
12 * published by the Free Software Foundation, either version 3 of *
13 * the License, or (at your option) any later version with the *
14 * following exceptions: *
15 * *
16 * If other files instantiate templates or use macros *
17 * or inline functions from this file, or you compile this file and *
18 * link it with other files to produce an executable, this file does *
19 * not by itself cause the resulting executable to be covered by the *
20 * GNU Lesser General Public License. This exception does not however *
21 * invalidate any other reasons why the executable file might be *
22 * covered by the GNU Lesser General Public License. *
23 * *
24 * OpenVolumeMesh is distributed in the hope that it will be useful, *
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27 * GNU Lesser General Public License for more details. *
28 * *
29 * You should have received a copy of the GNU LesserGeneral Public *
30 * License along with OpenVolumeMesh. If not, *
31 * see <http://www.gnu.org/licenses/>. *
32 * *
33 \*===========================================================================*/
34
35 /*===========================================================================*\
36 * *
37 * $Revision$ *
38 * $Date$ *
39 * $LastChangedBy$ *
40 * *
41 \*===========================================================================*/
42
43 #ifndef PROPERTYPTR_HH_
44 #define PROPERTYPTR_HH_
45
46 #include <string>
47
48 #include "BaseProperty.hh"
49 #include "OpenVolumeMeshHandle.hh"
50 #include "../System/MemoryInclude.hh"
51
52 namespace OpenVolumeMesh {
53
54 class ResourceManager;
55
64 template <class PropT, class HandleT>
65 class PropertyPtr : public ptr::shared_ptr<PropT>, public BaseProperty {
66 public:
67
68 friend class ResourceManager;
69
70 typedef typename PropT::value_type value_type;
71 typedef typename PropT::vector_type::const_iterator const_iterator;
72 typedef typename PropT::vector_type::iterator iterator;
73 typedef typename PropT::reference reference;
74 typedef typename PropT::const_reference const_reference;
75
77 PropertyPtr(PropT* _ptr, ResourceManager& _resMan, HandleT _handle);
78
80 virtual ~PropertyPtr();
81
82 virtual const std::string& name() const;
83
84 virtual void delete_element(size_t _idx);
85
86 virtual void swap_elements(size_t _idx0, size_t _idx1);
87
88 const_iterator begin() const { return ptr::shared_ptr<PropT>::get()->begin(); }
89 iterator begin() { return ptr::shared_ptr<PropT>::get()->begin(); }
90
91 const_iterator end() const { return ptr::shared_ptr<PropT>::get()->end(); }
92 iterator end() { return ptr::shared_ptr<PropT>::get()->end(); }
93
94 reference operator[](size_t _idx) { return (*ptr::shared_ptr<PropT>::get())[_idx]; }
95 const_reference operator[](size_t _idx) const { return (*ptr::shared_ptr<PropT>::get())[_idx]; }
96
97 reference operator[](const OpenVolumeMeshHandle& _h) { return (*ptr::shared_ptr<PropT>::get())[_h.idx()]; }
98 const_reference operator[](const OpenVolumeMeshHandle& _h) const { return (*ptr::shared_ptr<PropT>::get())[_h.idx()]; }
99
100 virtual OpenVolumeMeshHandle handle() const;
101
102 virtual bool persistent() const { return ptr::shared_ptr<PropT>::get()->persistent(); }
103
104 virtual bool anonymous() const { return ptr::shared_ptr<PropT>::get()->name().empty(); }
105
106 protected:
107
108 virtual void delete_multiple_entries(const std::vector<bool>& _tags);
109
110 virtual void resize(unsigned int _size);
111
112 virtual void set_handle(const OpenVolumeMeshHandle& _handle);
113 };
114
115 } // Namespace OpenVolumeMesh
116
117 #if defined(INCLUDE_TEMPLATES) && !defined(PROPERTYPTRT_CC)
118 #include "PropertyPtrT.cc"
119 #endif
120
121 #endif /* PROPERTYPTR_HH_ */
OpenVolumeMesh::ResourceManager
Definition: ResourceManager.hh:76
OpenVolumeMesh::PropertyPtr
Definition: PropertyPtr.hh:65
OpenVolumeMesh::BaseProperty
Definition: BaseProperty.hh:54
OpenVolumeMesh::OpenVolumeMeshHandle
Definition: OpenVolumeMeshHandle.hh:55
OpenVolumeMesh
Definition: ColorAttrib.hh:53
OpenVolumeMesh::PropertyPtr::PropertyPtr
PropertyPtr(PropT *_ptr, ResourceManager &_resMan, HandleT _handle)
Constructor.
Definition: PropertyPtrT.cc:52
OpenVolumeMesh::PropertyPtr::~PropertyPtr
virtual ~PropertyPtr()
Destructor.
Definition: PropertyPtrT.cc:58