fw4spl
Sequence.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 __FWATOMS_SEQUENCE_HPP__
8 #define __FWATOMS_SEQUENCE_HPP__
9 
10 #include "fwAtoms/Base.hpp"
11 #include "fwAtoms/config.hpp"
12 #include "fwAtoms/factory/new.hpp"
13 
14 #include <vector>
15 
16 namespace fwAtoms
17 {
22 class FWATOMS_CLASS_API Sequence : public Base
23 {
24 public:
25  fwCoreClassDefinitionsWithFactoryMacro( (Sequence)(::fwAtoms::Base), (()), ::fwAtoms::factory::New< Sequence > );
26 
27  typedef std::vector<Base::sptr> SequenceType;
28 
29  typedef SequenceType::value_type ValueType;
30  typedef SequenceType::reference ReferenceType;
31  typedef SequenceType::const_reference ConstReferenceType;
32  typedef SequenceType::iterator IteratorType;
33  typedef SequenceType::const_iterator ConstIteratorType;
34  typedef SequenceType::reverse_iterator ReverseIteratorType;
35  typedef SequenceType::const_reverse_iterator ConstReverseIteratorType;
36  typedef SequenceType::size_type SizeType;
37 
40  typedef SequenceType::value_type value_type;
41  typedef SequenceType::reference reference;
42  typedef SequenceType::const_reference const_reference;
43  typedef SequenceType::iterator iterator;
44  typedef SequenceType::const_iterator const_iterator;
45  typedef SequenceType::reverse_iterator reverse_iterator;
46  typedef SequenceType::const_reverse_iterator const_reverse_iterator;
47  typedef SequenceType::size_type size_type;
49 
55  {
56  }
57 
61  virtual ~Sequence()
62  {
63  }
64 
68  void push_back(const Base::sptr& value)
69  {
70  m_value.push_back(value);
71  }
72 
74  IteratorType begin()
75  {
76  return m_value.begin();
77  }
78 
80  IteratorType end()
81  {
82  return m_value.end();
83  }
84 
86  ConstIteratorType begin() const
87  {
88  return m_value.begin();
89  }
90 
92  ConstIteratorType end() const
93  {
94  return m_value.end();
95  }
96 
98  size_type size() const
99  {
100  return m_value.size();
101  }
102 
104  void clear()
105  {
106  m_value.clear();
107  }
108 
110  bool empty() const
111  {
112  return m_value.empty();
113  }
114 
116  const SequenceType& getValue() const
117  {
118  return m_value;
119  }
120 
122  Base::sptr& operator[](unsigned int index)
123  {
124  return m_value[index];
125  }
126  //------------------------------------------------------------------------------
127 
128  const Base::sptr& operator[](unsigned int index) const
129  {
130  return m_value[index];
131  }
132 
136  FWATOMS_API virtual Base::sptr clone() const override;
137 
141  ::fwAtoms::Base::AtomType type() const override
142  {
143  return ::fwAtoms::Base::SEQUENCE;
144  }
145 
146 protected:
147  SequenceType m_value;
148 };
149 
150 }
151 #endif //__FWATOMS_SEQUENCE_HPP__
152 
virtual ~Sequence()
Destructor.
Definition: Sequence.hpp:61
bool empty() const
Test if the sequence is empty.
Definition: Sequence.hpp:110
void push_back(const Base::sptr &value)
push an atom in the sequence.
Definition: Sequence.hpp:68
ConstIteratorType begin() const
Begin of sequence const iterator.
Definition: Sequence.hpp:86
fwAtoms contains basic objects to represent any other kind of object
IteratorType begin()
Begin of sequence iterator.
Definition: Sequence.hpp:74
::fwAtoms::Base::AtomType type() const override
returns Atom type
Definition: Sequence.hpp:141
SequenceType::const_iterator const_iterator
Definition: Sequence.hpp:44
const SequenceType & getValue() const
Returns internal vector.
Definition: Sequence.hpp:116
Sequence(::fwAtoms::Base::Key key)
Constructor.
Definition: Sequence.hpp:54
ConstIteratorType end() const
End of sequence const iterator.
Definition: Sequence.hpp:92
SequenceType::const_reverse_iterator const_reverse_iterator
Definition: Sequence.hpp:46
SequenceType::value_type value_type
Definition: Sequence.hpp:40
SequenceType::iterator iterator
Definition: Sequence.hpp:43
IteratorType end()
End of sequence iterator.
Definition: Sequence.hpp:80
SequenceType::const_reference const_reference
Definition: Sequence.hpp:42
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
size_type size() const
Returns the sequence size.
Definition: Sequence.hpp:98
SequenceType::reverse_iterator reverse_iterator
Definition: Sequence.hpp:45
Base::sptr & operator[](unsigned int index)
access an element in position index
Definition: Sequence.hpp:122
SequenceType::size_type size_type
Definition: Sequence.hpp:47
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Base class for all Atom classes.
void clear()
clear the sequence
Definition: Sequence.hpp:104
SequenceType::reference reference
Definition: Sequence.hpp:41
Sequence represented a list of meta object.
Definition: Sequence.hpp:22