MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
mlPropertyContainer.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2010, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_PROPERTY_CONTAINER_H
14#define ML_PROPERTY_CONTAINER_H
15
16
18
19#include "mlVesselGraphSystem.h"
20
21#include "mlPropertyValue.h"
22#include "mlPropertyManager.h"
23
24#include <vector>
25#include <boost/shared_ptr.hpp>
26
27class MLPropertyContainerWrapper;
28
30
32{
33 friend class PropertyManager;
34 friend class ::MLPropertyContainerWrapper;
35
36public:
40
44
49 {
50 return !(*this == other);
51 }
52
55
58 {
59 return _manager.get();
60 }
63 {
64 return _manager.get();
65 }
68
70 size_t numberOfProperties() const
71 {
72 return _values.size();
73 }
74
76 // PropertyValue& property(size_t index) { return _values[index]; }
78 const PropertyValue& property(size_t index) const
79 {
80 return _values[index];
81 }
84 template <typename T> T& property(size_t index)
85 {
86 return _values[index].get<T>();
87 }
90 template <typename T> const T& property(size_t index) const
91 {
92 return _values[index].get<T>();
93 }
94
101 // PropertyValue& property(const std::string& name) { return _values[_manager->getPropertyIndex(name)]; }
102 const PropertyValue& property(const std::string& name) const
103 {
104 return _values[_manager->getPropertyIndex(name)];
105 }
106 template <typename T> T& property(const std::string& name)
107 {
108 return _values[_manager->getPropertyIndex(name)].get<T>();
109 }
110 template <typename T> const T& property(const std::string& name) const
111 {
112 return _values[_manager->getPropertyIndex(name)].get<T>();
113 }
114
116 virtual void reset();
117
118protected:
119 std::vector<PropertyValue> _values;
120
122
123private:
124 PropertyContainer& operator=(const PropertyContainer& other); // not implemented
125
126public:
130 void addStateToTree(TreeNode* parent) const override;
131
134
136 void readStateFromTree(TreeNode* parent) override;
138
140};
141
143
144#endif // __MLPropertyContainer_H
@ T
const PropertyValue & property(const std::string &name) const
Get the property with name name.
std::vector< PropertyValue > _values
PropertyManager::Pointer ManagerPointer
~PropertyContainer() override
const PropertyValue & property(size_t index) const
Get the property with index index as PropertyValue.
PropertyContainer(const ManagerPointer &manager)
void addStateToTree(TreeNode *parent) const override
bool operator==(const PropertyContainer &other) const
Check for equality (managers and values).
const T & property(const std::string &name) const
void copyProperties(const PropertyContainer &other)
Copy all properties from the given container to this object.
PropertyContainer(const PropertyContainer &other)
PropertyMap getPropertyMap() const
Get a map of the contained properties, can be useful for comparison.
T & property(size_t index)
Get the property with index index with type T.
const T & property(size_t index) const
Get the property with index index with type T, const version.
const PropertyManager * getPropertyManager() const
Get read-only access to the associated property manager.
virtual void reset()
Set all properties to default values.
PropertyManager::ConstPointer ConstManagerPointer
PropertyManager::PropertyMap PropertyMap
T & property(const std::string &name)
ML_ABSTRACT_CLASS_HEADER(PropertyContainer)
bool operator!=(const PropertyContainer &other) const
Check for inequality (managers and values).
size_t numberOfProperties() const
Return the number of properties currently available.
PropertyManager * getPropertyManager()
Get access to the associated property manager.
void readStateFromTree(TreeNode *parent) override
Reads the object state from the children of the given parent node.
ML_SET_ADDSTATE_VERSION(1)
Set current addStateToTree() version number:
boost::intrusive_ptr< const type > ConstPointer
boost::intrusive_ptr< type > Pointer
std::map< std::string, PropertyValue > PropertyMap
Class PropertyValue, which is used to hold properties of a given set of allowed types in typesafe way...
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
#define VESSELGRAPH_END_NAMESPACE
#define VESSELGRAPH_EXPORT
Definiert systemspezifische Macros, die f"ur diese DLL gelten sollen.
#define VESSELGRAPH_BEGIN_NAMESPACE