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 
27 class MLPropertyContainerWrapper;
28 
30 
32  friend class PropertyManager;
33  friend class ::MLPropertyContainerWrapper;
34 public:
38 
41  ~PropertyContainer() override;
42 
44  bool operator==(const PropertyContainer& other) const;
46  bool operator!=(const PropertyContainer& other) const { return !(*this==other); }
47 
49  void copyProperties(const PropertyContainer& other);
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 
88 protected:
89  std::vector<PropertyValue> _values;
90 
92 
93 private:
94  PropertyContainer& operator=(const PropertyContainer& other); // not implemented
95 
96 public:
100  void addStateToTree(TreeNode* parent) const override;
101 
104 
106  void readStateFromTree(TreeNode* parent) override;
108 
110 };
111 
113 
114 #endif // __MLPropertyContainer_H
@ T
Definition: SoKeyGrabber.h:71
std::vector< PropertyValue > _values
PropertyManager::Pointer ManagerPointer
~PropertyContainer() override
PropertyContainer(const ManagerPointer &manager)
const PropertyValue & property(const std::string &name) const
Get the property with name name.
void addStateToTree(TreeNode *parent) const override
PropertyManager * getPropertyManager()
Get access to the associated property manager.
bool operator==(const PropertyContainer &other) const
Check for equality (managers and values).
void copyProperties(const PropertyContainer &other)
Copy all properties from the given container to this object.
const T & property(const std::string &name) const
PropertyContainer(const PropertyContainer &other)
const PropertyManager * getPropertyManager() const
Get read-only access to the associated property manager.
PropertyMap getPropertyMap() const
Get a map of the contained properties, can be useful for comparison.
virtual void reset()
Set all properties to default values.
ManagerPointer _manager
PropertyManager::ConstPointer ConstManagerPointer
T & property(const std::string &name)
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 PropertyValue & property(size_t index) const
Get the property with index index as PropertyValue.
PropertyManager::PropertyMap PropertyMap
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.
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:
T & property(size_t index)
Get the property with index index with type T. Throws boost::bad_get exception if the currently store...
PropertyManager & operator=(const PropertyManager &item)
Assignment operator. Resets all registered GraphProperties.
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...
#define VESSELGRAPH_END_NAMESPACE
#define VESSELGRAPH_EXPORT
Definiert systemspezifische Macros, die f"ur diese DLL gelten sollen.
#define VESSELGRAPH_BEGIN_NAMESPACE