OTB  6.7.0
Orfeo Toolbox
otbObjectList.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbObjectList_h
22 #define otbObjectList_h
23 
24 #include <vector>
25 #include "itkDataObject.h"
27 #include "itkObjectFactory.h"
28 
29 namespace otb
30 {
39 template <class TObject>
40 class ITK_EXPORT ObjectList : public itk::DataObject , public DataObjectListInterface
41 {
42 public:
44  typedef ObjectList Self;
48 
50  itkTypeMacro(ObjectList, DataObject);
51 
53  itkNewMacro(Self);
54 
56  typedef TObject ObjectType;
58  typedef std::vector<ObjectPointerType> InternalContainerType;
59  typedef typename InternalContainerType::size_type InternalContainerSizeType;
60 
65  void Reserve(InternalContainerSizeType size);
66 
71  InternalContainerSizeType Capacity(void) const;
72 
77  InternalContainerSizeType Size(void) const override;
78 
83  void Resize(InternalContainerSizeType size);
84 
89  void PushBack(ObjectType* element);
90 
94  void PopBack(void);
95 
101  void SetNthElement(unsigned int index, ObjectPointerType element);
102  void SetNthElement(unsigned int index, const ObjectType * element);
103 
109  ObjectPointerType GetNthElement(unsigned int index) const;
110 
115  Superclass * GetNthDataObject(unsigned int index) const override;
116 
121  ObjectPointerType Front(void);
122 
127  ObjectPointerType Back(void);
128 
133  void Erase(unsigned int index);
134 
138  void Clear(void);
139 
140  class ConstIterator;
141  class ReverseIterator;
142  class ReverseConstIterator;
143  class Iterator;
144  friend class Iterator;
145  friend class ConstIterator;
146  friend class ReverseIterator;
147  friend class ReverseConstIterator;
148 
154  Iterator Insert(Iterator position, ObjectPointerType element);
155 
161  ReverseIterator Insert(ReverseIterator position, ObjectPointerType element);
162 
168  class ITK_EXPORT Iterator
169  {
170 public:
171  friend class ObjectList;
172  friend class ConstIterator;
174  typedef typename InternalContainerType::iterator InternalIteratorType;
175 
177  Iterator() {};
178 
181  {
182  m_Iter = iter;
183  };
184 
190  {
191  return (*m_Iter);
192  }
193 
197  void Set(ObjectPointerType element)
198  {
199  (*m_Iter) = element;
200  }
201 
205  Iterator & operator ++()
206  {
207  ++m_Iter;
208  return *this;
209  }
210 
214  Iterator & operator --()
215  {
216  --m_Iter;
217  return *this;
218  }
219 
223  Iterator operator +(int i)
224  {
225  Iterator lIter(m_Iter + i);
226  return lIter;
227  }
228 
232  Iterator operator -(int i)
233  {
234  Iterator lIter(m_Iter - i);
235  return lIter;
236  }
237 
240  Iterator
241  operator += ( int i )
242  {
243  return m_Iter + i;
244  }
245 
248  Iterator
249  operator -= ( int i )
250  {
251  return m_Iter - i;
252  }
253 
257  bool operator !=(const Iterator& it)
258  {
259  return (m_Iter != it.m_Iter);
260  }
261 
265  bool operator ==(const Iterator& it)
266  {
267  return (m_Iter == it.m_Iter);
268  }
269 
273  Iterator & operator =(const Iterator& it)
274  {
275  m_Iter = it.m_Iter;
276  return *this;
277  }
278 
282  Iterator(const Iterator &it)
283  {
284  m_Iter = it.m_Iter;
285  };
286 
291  {
292  return (m_Iter);
293  }
294 private:
295  // Internal iterator.
297  };
298 
303 
627 
633 
639 
645 
651 
657 
663 
669 
676 
682 
686 
692 
698 
InternalContainerType::size_type InternalContainerSizeType
Definition: otbObjectList.h:59
InternalIteratorType & GetIter(void)
OTBGdalAdapters_EXPORT bool operator==(const CoordinateTransformation &ct1, const CoordinateTransformation &ct2) noexcept
equal operator
InternalIteratorType m_Iter
Iterator of the object list.
ObjectPointerType Get(void)
TObject ObjectType
Definition: otbObjectList.h:53
itk::SmartPointer< ObjectType > ObjectPointerType
Definition: otbObjectList.h:57
This class is a generic all-purpose wrapping around an std::vector<itk::SmartPointer<ObjectType> >...
Definition: otbObjectList.h:40
OTBGdalAdapters_EXPORT bool operator!=(const CoordinateTransformation &ct1, const CoordinateTransformation &ct2) noexcept
different operator
InternalContainerType::iterator InternalIteratorType
ConstIterator of the object list.
Iterator(const Iterator &it)
itk::SmartPointer< const Self > ConstPointer
Definition: otbObjectList.h:47
itk::SmartPointer< Self > Pointer
Definition: otbObjectList.h:46
std::vector< ObjectPointerType > InternalContainerType
Definition: otbObjectList.h:58
This class is a sampling rate calculator.
void Set(ObjectPointerType element)
Iterator(InternalIteratorType iter)
ObjectList Self
Definition: otbObjectList.h:44
itk::DataObject Superclass
Definition: otbObjectList.h:45