MeVisLab Toolbox Reference
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 friend class PropertyManager;
33 friend class ::MLPropertyContainerWrapper;
34public:
38
42
46 bool operator!=(const PropertyContainer& other) const { return !(*this==other); }
47
50
52 const PropertyManager* getPropertyManager() const { return _manager.get(); }
54 PropertyManager* getPropertyManager() { return _manager.get(); }
57
59 size_t numberOfProperties() const { return _values.size(); }
60
62 //PropertyValue& property(size_t index) { return _values[index]; }
64 const PropertyValue& property(size_t index) const { return _values[index]; }
66 template<typename T>
67 T& property(size_t index) { return _values[index].get<T>(); }
69 template<typename T>
70 const T& property(size_t index) const { return _values[index].get<T>(); }
71
78 // PropertyValue& property(const std::string& name) { return _values[_manager->getPropertyIndex(name)]; }
79 const PropertyValue& property(const std::string& name) const { return _values[_manager->getPropertyIndex(name)]; }
80 template<typename T>
81 T& property(const std::string& name) { return _values[_manager->getPropertyIndex(name)].get<T>(); }
82 template<typename T>
83 const T& property(const std::string& name) const { return _values[_manager->getPropertyIndex(name)].get<T>(); }
84
86 virtual void reset();
87
88protected:
89 std::vector<PropertyValue> _values;
90
92
93private:
94 PropertyContainer& operator=(const PropertyContainer& other); // not implemented
95
96public:
100 void addStateToTree(TreeNode* parent) const override;
101
104
106 void readStateFromTree(TreeNode* parent) override;
108
110};
111
113
114#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. Throws boost::bad_get exception if the currently store...
const T & property(size_t index) const
Get the property with index index with type T, const version. Throws boost::bad_get exception if the ...
const PropertyManager * getPropertyManager() const
Get read-only access to the associated property manager.
virtual void reset()
Set all properties to default values.
ManagerPointer _manager
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