fw4spl
SrcLib/core/fwData/include/fwData/List.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
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 __FWDATA_LIST_HPP__
8 #define __FWDATA_LIST_HPP__
9 
10 #include "fwData/config.hpp"
11 #include "fwData/factory/new.hpp"
12 #include "fwData/Object.hpp"
13 
14 #include <list>
15 
16 fwCampAutoDeclareDataMacro((fwData)(List), FWDATA_API);
17 
18 namespace fwData
19 {
20 
26 class FWDATA_CLASS_API List : public Object
27 {
28 
29 public:
30 
31  fwCoreClassDefinitionsWithFactoryMacro( (List)(::fwData::Object), (()), ::fwData::factory::New< List >);
32 
33  fwCampMakeFriendDataMacro((fwData)(List));
34 
35  typedef std::list< Object::sptr > ContainerType;
36 
37  typedef ContainerType::value_type ValueType;
38  typedef ContainerType::reference ReferenceType;
39  typedef ContainerType::const_reference ConstReferenceType;
40  typedef ContainerType::iterator IteratorType;
41  typedef ContainerType::const_iterator ConstIteratorType;
42  typedef ContainerType::reverse_iterator ReverseIteratorType;
43  typedef ContainerType::const_reverse_iterator ConstReverseIteratorType;
44  typedef ContainerType::size_type SizeType;
45 
50  FWDATA_API List(::fwData::Object::Key key);
51 
53  FWDATA_API virtual ~List();
54 
57  typedef ContainerType::value_type value_type;
58  typedef ContainerType::iterator iterator;
59  typedef ContainerType::const_iterator const_iterator;
60  typedef ContainerType::reverse_iterator reverse_iterator;
61  typedef ContainerType::const_reverse_iterator const_reverse_iterator;
62  typedef ContainerType::size_type size_type;
63 
64  typedef List Container;
65 
66  IteratorType begin();
67  IteratorType end();
68  ConstIteratorType begin() const;
69  ConstIteratorType end() const;
70 
71  ReverseIteratorType rbegin();
72  ReverseIteratorType rend();
73  ConstReverseIteratorType rbegin() const;
74  ConstReverseIteratorType rend() const;
75 
76  bool empty() const;
77  SizeType size() const;
78 
79  ReferenceType front();
80  ReferenceType back();
81  ConstReferenceType front() const;
82  ConstReferenceType back() const;
84 
87  ContainerType& getContainer();
88  const ContainerType& getContainer () const;
89  void setContainer (const ContainerType& val);
91 
93  FWDATA_API void shallowCopy( const Object::csptr& _source ) override;
94 
96  FWDATA_API void cachedDeepCopy(const Object::csptr& _source, DeepCopyCacheType& cache) override;
97 
98 protected:
99 
100  ContainerType m_container;
101 };
102 
103 //-----------------------------------------------------------------------------
104 
105 inline List::IteratorType List::begin()
106 {
107  return m_container.begin();
108 }
109 
110 //-----------------------------------------------------------------------------
111 
112 inline List::IteratorType List::end()
113 {
114  return m_container.end();
115 }
116 
117 //-----------------------------------------------------------------------------
118 
119 inline List::ConstIteratorType List::begin() const
120 {
121  return m_container.begin();
122 }
123 
124 //-----------------------------------------------------------------------------
125 
126 inline List::ConstIteratorType List::end() const
127 {
128  return m_container.end();
129 }
130 
131 //-----------------------------------------------------------------------------
132 
133 inline List::ReverseIteratorType List::rbegin()
134 {
135  return m_container.rbegin();
136 }
137 
138 //-----------------------------------------------------------------------------
139 
140 inline List::ReverseIteratorType List::rend()
141 {
142  return m_container.rend();
143 }
144 
145 //-----------------------------------------------------------------------------
146 
147 inline List::ConstReverseIteratorType List::rbegin() const
148 {
149  return m_container.rbegin();
150 }
151 
152 //-----------------------------------------------------------------------------
153 
154 inline List::ConstReverseIteratorType List::rend() const
155 {
156  return m_container.rend();
157 }
158 
159 //-----------------------------------------------------------------------------
160 
161 inline bool List::empty() const
162 {
163  return m_container.empty();
164 }
165 
166 //-----------------------------------------------------------------------------
167 
168 inline List::SizeType List::size() const
169 {
170  return m_container.size();
171 }
172 
173 //-----------------------------------------------------------------------------
174 
175 inline List::ReferenceType List::front()
176 {
177  return m_container.front();
178 }
179 
180 //-----------------------------------------------------------------------------
181 
182 inline List::ReferenceType List::back()
183 {
184  return m_container.back();
185 }
186 
187 //-----------------------------------------------------------------------------
188 
189 inline List::ConstReferenceType List::front() const
190 {
191  return m_container.front();
192 }
193 
194 //-----------------------------------------------------------------------------
195 
196 inline List::ConstReferenceType List::back() const
197 {
198  return m_container.back();
199 }
200 
201 //-----------------------------------------------------------------------------
202 
203 inline List::ContainerType& List::getContainer()
204 {
205  return m_container;
206 }
207 
208 //-----------------------------------------------------------------------------
209 
210 inline const List::ContainerType& List::getContainer () const
211 {
212  return m_container;
213 }
214 
215 //-----------------------------------------------------------------------------
216 
217 inline void List::setContainer (const List::ContainerType& val)
218 { \
219  m_container = val;
220 }
221 
222 //-----------------------------------------------------------------------------
223 
224 } // namespace fwData
225 
226 #endif /* __FWDATA_LIST_HPP__ */
227 
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
ContainerType::size_type size_type
ContainerType & getContainer()
get/set the list of fwData::Object
ContainerType::const_reverse_iterator const_reverse_iterator
This class defines a list of objects.
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
void setContainer(const ContainerType &val)
get/set the list of fwData::Object
Base class for each data object.
ContainerType::const_iterator const_iterator
Contains the representation of the data objects used in the framework.
ContainerType::value_type value_type
ContainerType::reverse_iterator reverse_iterator