MeVisLabToolboxReference
MeVisLab/Standard/Sources/ML/MLVesselGraph/Properties/mlPropertyContainer.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00004 
00009 //----------------------------------------------------------------------------------
00010 
00011 #ifndef __MLPropertyContainer_H
00012 #define __MLPropertyContainer_H
00013 
00014 #include "mlVesselGraphSystem.h"
00015 
00016 #include "mlPropertyValue.h"
00017 #include "mlPropertyManager.h"
00018 
00019 #include <vector>
00020 #include <boost/shared_ptr.hpp>
00021 
00022 #include <mlBase.h>
00023 
00024 class MLPropertyContainerWrapper;
00025 
00026 ML_START_NAMESPACE
00027 
00028 class VESSELGRAPH_EXPORT PropertyContainer : public Base {
00029   friend class PropertyManager;
00030   friend class ::MLPropertyContainerWrapper;
00031 public:
00032   typedef PropertyManager::Pointer ManagerPointer;
00033   typedef PropertyManager::ConstPointer ConstManagerPointer;
00034   typedef PropertyManager::PropertyMap PropertyMap;
00035 
00036   PropertyContainer(const ManagerPointer& manager);
00037   PropertyContainer(const PropertyContainer& other);
00038   virtual ~PropertyContainer();
00039 
00041   virtual bool operator==(const PropertyContainer& other) const;
00043   virtual bool operator!=(const PropertyContainer& other) const { return !(*this==other); }
00044 
00046   virtual void copyProperties(const PropertyContainer& other);
00047 
00049   const PropertyManager* getPropertyManager() const { return _manager.get(); }
00051   PropertyManager* getPropertyManager() { return _manager.get(); }
00053   PropertyMap getPropertyMap() const;
00054 
00056   size_t numberOfProperties() const { return _values.size(); }
00057 
00059   //PropertyValue& property(size_t index) { return _values[index]; }
00061   const PropertyValue& property(size_t index) const { return _values[index]; }
00063   template<typename T>
00064   T& property(size_t index) { return _values[index].get<T>(); }
00066   template<typename T>
00067   const T& property(size_t index) const { return _values[index].get<T>(); }
00068 
00075   // PropertyValue& property(const std::string& name)             { return _values[_manager->getPropertyIndex(name)]; }
00076   const PropertyValue& property(const std::string& name) const { return _values[_manager->getPropertyIndex(name)]; }
00077   template<typename T>
00078   T& property(const std::string& name) { return _values[_manager->getPropertyIndex(name)].get<T>(); }
00079   template<typename T>
00080   const T& property(const std::string& name) const { return _values[_manager->getPropertyIndex(name)].get<T>(); }
00081 
00083   virtual void reset();
00084 
00086 
00087 
00088   virtual void addStateToTree(TreeNode* parent) const;
00089 
00091   ML_SET_ADDSTATE_VERSION(1);
00092 
00094   virtual void readStateFromTree(TreeNode* parent);
00096 
00097 protected:
00098   std::vector<PropertyValue> _values;
00099 
00100   ManagerPointer _manager;
00101 
00102 private:
00103   PropertyContainer& operator=(const PropertyContainer& other); // not implemented
00104 
00105   ML_ABSTRACT_CLASS_HEADER(PropertyContainer);
00106 };
00107 
00108 ML_END_NAMESPACE
00109 
00110 #endif // __MLPropertyContainer_H