fw4spl
MapProperty.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __FWCAMP_CAMP_MAPPROPERTY_HPP__
8 #define __FWCAMP_CAMP_MAPPROPERTY_HPP__
9 
10 #include <camp/property.hpp>
11 #include <camp/value.hpp>
12 #include <camp/userobject.hpp>
13 #include <camp/camptype.hpp>
14 
15 #include "fwCamp/config.hpp"
16 
17 namespace camp
18 {
19 
20 class FWCAMP_CLASS_API MapProperty : public Property
21 {
22 public:
23 
24  typedef std::pair< Value, Value > ValuePair;
25  typedef std::pair< UserObject, UserObject> ObjectPair;
26 
27  FWCAMP_API MapProperty(const std::string& name, Type elementType);
31  FWCAMP_API virtual ~MapProperty();
32 
38  FWCAMP_API Type elementType() const;
39 
49  FWCAMP_API virtual Value getValue(const UserObject& object) const;
50 
59  FWCAMP_API virtual void setValue(const UserObject& object, const Value& value) const;
60 
61 
69  FWCAMP_API virtual std::size_t getSize(const UserObject& object) const = 0;
70 
76  FWCAMP_API virtual void accept(ClassVisitor& visitor) const;
77 
78  FWCAMP_API virtual ValuePair getElement(const UserObject& object, std::size_t index) const = 0;
79 
80  FWCAMP_API virtual void set(const UserObject& object, const Value& key, const Value& value) const = 0;
81 
82 private:
83 
84  Type m_elementType;
85 };
86 
87 } // namespace camp
88 
89 CAMP_TYPE(camp::MapProperty::ValuePair);
90 
91 #endif /* __FWCAMP_CAMP_MAPPROPERTY_HPP__ */