fw4spl
MapPropertyImpl.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_DETAIL_MAPPROPERTYIMPL_HPP__
8 #define __FWCAMP_CAMP_DETAIL_MAPPROPERTYIMPL_HPP__
9 
10 #include "fwCamp/camp/MapValueMapper.hpp"
11 #include "fwCamp/camp/MapMapper.hpp"
12 #include "fwCamp/camp/MapProperty.hpp"
13 
14 namespace camp
15 {
16 namespace detail
17 {
18 
19 template <typename A>
20 class MapPropertyImpl : public MapProperty
21 {
22 public:
23 
24  typedef MapProperty::ValuePair ValuePair;
25  typedef MapProperty::ObjectPair ObjectPair;
26 
33  MapPropertyImpl(const std::string& name, const A& accessor);
34 
35 protected:
36 
40  virtual std::size_t getSize(const UserObject& object) const;
41 
42  MapProperty::ValuePair getElement(const UserObject& object, std::size_t index ) const;
43 
44  virtual void set(const UserObject& object, const Value& key, const Value& value) const;
45 
46 private:
47 
48  typedef typename boost::remove_reference<typename A::DataType>::type MapType;
49  typedef camp_ext::MapMapper<MapType> Mapper;
50  typedef typename Mapper::ValueType ValueType;
51 
59  MapType& map(const UserObject& object) const;
60 
61  A m_accessor;
62 };
63 
64 
65 } // namespace detail
66 } // namespace camp
67 
68 #include "fwCamp/camp/detail/MapPropertyImpl.hxx"
69 
70 #endif /* __FWCAMP_CAMP_DETAIL_MAPPROPERTYIMPL_HPP__ */
virtual FWCAMP_API std::size_t getSize(const UserObject &object) const =0
Do the actual retrieval of the size.