fw4spl
core/fwMedData/include/fwMedData/SeriesDB.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 __FWMEDDATA_SERIESDB_HPP__
8 #define __FWMEDDATA_SERIESDB_HPP__
9 
10 #include "fwMedData/config.hpp"
11 #include "fwMedData/types.hpp"
12 
13 #include <fwCom/Signal.hpp>
14 #include <fwCom/Signals.hpp>
15 
16 #include <fwData/factory/new.hpp>
17 #include <fwData/Object.hpp>
18 
19 #include <vector>
20 
21 fwCampAutoDeclareDataMacro((fwMedData)(SeriesDB), FWMEDDATA_API);
22 
23 namespace fwMedData
24 {
25 
26 class Series;
27 
31 class FWMEDDATA_CLASS_API SeriesDB : public ::fwData::Object
32 {
33 
34 public:
35  fwCoreClassDefinitionsWithFactoryMacro( (SeriesDB)(::fwData::Object), (()), ::fwData::factory::New< SeriesDB >);
36 
37  fwCampMakeFriendDataMacro((fwMedData)(SeriesDB));
38 
39  typedef std::vector< SPTR(Series) > ContainerType;
40 
41  typedef ContainerType::value_type ValueType;
42  typedef ContainerType::reference ReferenceType;
43  typedef ContainerType::const_reference ConstReferenceType;
44  typedef ContainerType::iterator IteratorType;
45  typedef ContainerType::const_iterator ConstIteratorType;
46  typedef ContainerType::reverse_iterator ReverseIteratorType;
47  typedef ContainerType::const_reverse_iterator ConstReverseIteratorType;
48  typedef ContainerType::size_type SizeType;
49 
52  typedef ContainerType::value_type value_type;
53  typedef ContainerType::iterator iterator;
54  typedef ContainerType::const_iterator const_iterator;
55  typedef ContainerType::reverse_iterator reverse_iterator;
56  typedef ContainerType::const_reverse_iterator const_reverse_iterator;
57  typedef ContainerType::size_type size_type;
58 
59  IteratorType begin();
60  IteratorType end();
61  ConstIteratorType begin() const;
62  ConstIteratorType end() const;
63 
64  ReverseIteratorType rbegin();
65  ReverseIteratorType rend();
66  ConstReverseIteratorType rbegin() const;
67  ConstReverseIteratorType rend() const;
68 
69  bool empty() const;
70  SizeType size() const;
71 
72  ValueType front();
73  ValueType back();
74 
75  ReferenceType operator[] ( size_type n );
76  ConstReferenceType operator[] ( size_type n ) const;
77 
78  ReferenceType at ( SizeType n );
79  ConstReferenceType at ( SizeType n ) const;
81 
86  FWMEDDATA_API SeriesDB(::fwData::Object::Key key);
87 
89  FWMEDDATA_API virtual ~SeriesDB();
90 
92  FWMEDDATA_API void shallowCopy( const ::fwData::Object::csptr& _source ) override;
93 
95  FWMEDDATA_API void cachedDeepCopy( const ::fwData::Object::csptr& _source, DeepCopyCacheType& cache ) override;
96 
104  ContainerType& getContainer();
105  const ContainerType& getContainer () const;
106  void setContainer (const ContainerType& val);
115  typedef ::fwCom::Signal< void (ContainerType) > AddedSeriesSignalType;
117  FWMEDDATA_API static const ::fwCom::Signals::SignalKeyType s_ADDED_SERIES_SIG;
118 
120  typedef ::fwCom::Signal< void (ContainerType) > RemovedSeriesSignalType;
121  FWMEDDATA_API static const ::fwCom::Signals::SignalKeyType s_REMOVED_SERIES_SIG;
126 protected:
127 
129  ContainerType m_container;
130 
131 };
132 
133 //-----------------------------------------------------------------------------
134 
135 inline SeriesDB::IteratorType SeriesDB::begin()
136 {
137  return m_container.begin();
138 }
139 
140 //-----------------------------------------------------------------------------
141 
142 inline SeriesDB::IteratorType SeriesDB::end()
143 {
144  return m_container.end();
145 }
146 
147 //-----------------------------------------------------------------------------
148 
149 inline SeriesDB::ConstIteratorType SeriesDB::begin() const
150 {
151  return m_container.begin();
152 }
153 
154 //-----------------------------------------------------------------------------
155 
156 inline SeriesDB::ConstIteratorType SeriesDB::end() const
157 {
158  return m_container.end();
159 }
160 
161 //-----------------------------------------------------------------------------
162 
163 inline SeriesDB::ReverseIteratorType SeriesDB::rbegin()
164 {
165  return m_container.rbegin();
166 }
167 
168 //-----------------------------------------------------------------------------
169 
170 inline SeriesDB::ReverseIteratorType SeriesDB::rend()
171 {
172  return m_container.rend();
173 }
174 
175 //-----------------------------------------------------------------------------
176 
177 inline SeriesDB::ConstReverseIteratorType SeriesDB::rbegin() const
178 {
179  return m_container.rbegin();
180 }
181 
182 //-----------------------------------------------------------------------------
183 
184 inline SeriesDB::ConstReverseIteratorType SeriesDB::rend() const
185 {
186  return m_container.rend();
187 }
188 
189 //-----------------------------------------------------------------------------
190 
191 inline bool SeriesDB::empty() const
192 {
193  return m_container.empty();
194 }
195 
196 //-----------------------------------------------------------------------------
197 
198 inline SeriesDB::SizeType SeriesDB::size() const
199 {
200  return m_container.size();
201 }
202 
203 //-----------------------------------------------------------------------------
204 
205 inline SeriesDB::ValueType SeriesDB::front()
206 {
207  return m_container.front();
208 }
209 
210 //-----------------------------------------------------------------------------
211 
212 inline SeriesDB::ValueType SeriesDB::back()
213 {
214  return m_container.back();
215 }
216 
217 //-----------------------------------------------------------------------------
218 
219 inline SeriesDB::ReferenceType SeriesDB::operator[](SeriesDB::size_type n)
220 {
221  return this->m_container[n];
222 }
223 
224 //-----------------------------------------------------------------------------
225 
226 inline SeriesDB::ConstReferenceType SeriesDB::operator[](SeriesDB::size_type n) const
227 {
228  return this->m_container[n];
229 }
230 
231 //-----------------------------------------------------------------------------
232 
233 inline SeriesDB::ReferenceType SeriesDB::at(SeriesDB::SizeType n)
234 {
235  return m_container.at(n);
236 }
237 
238 //-----------------------------------------------------------------------------
239 
240 inline SeriesDB::ConstReferenceType SeriesDB::at(SeriesDB::SizeType n) const
241 {
242  return m_container.at(n);
243 }
244 
245 //-----------------------------------------------------------------------------
246 
247 inline SeriesDB::ContainerType& SeriesDB::getContainer()
248 {
249  return m_container;
250 }
251 
252 //-----------------------------------------------------------------------------
253 
254 inline const SeriesDB::ContainerType& SeriesDB::getContainer () const
255 {
256  return m_container;
257 }
258 
259 //-----------------------------------------------------------------------------
260 
261 inline void SeriesDB::setContainer (const SeriesDB::ContainerType& val)
262 {
263  m_container = val;
264 }
265 
266 //-----------------------------------------------------------------------------
267 
268 } //end namespace fwMedData
269 
270 #endif // __FWMEDDATA_SERIESDB_HPP__
271 
ContainerType::const_reverse_iterator const_reverse_iterator
Namespace containing medical data.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
ContainerType::const_iterator const_iterator
void setContainer(const ContainerType &val)
Series container.
static FWMEDDATA_APIconst::fwCom::Signals::SignalKeyType s_ADDED_SERIES_SIG
Type of signal when series are added.
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
static FWMEDDATA_APIconst::fwCom::Signals::SignalKeyType s_REMOVED_SERIES_SIG
Type of signal when series are added.
Base class for each data object.
ContainerType & getContainer()
Series container.
ContainerType m_container
Series container.
::fwCom::Signal< void(ContainerType) > RemovedSeriesSignalType
Type of signal when series are removed.
ContainerType::reverse_iterator reverse_iterator