ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkRingBuffer.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkRingBuffer_h
19 #define itkRingBuffer_h
20 
21 #include "itkObject.h"
22 #include "itkObjectFactory.h"
23 #include "itkIntTypes.h"
24 
25 namespace itk
26 {
38 template< typename TElement >
39 class ITK_TEMPLATE_EXPORT RingBuffer : public Object
40 {
41 public:
42  ITK_DISALLOW_COPY_AND_ASSIGN(RingBuffer);
43 
47  using Self = RingBuffer;
48  using Superclass = Object;
51 
53  using ElementType = TElement;
54  using ElementPointer = typename ElementType::Pointer;
55 
58 
60  itkNewMacro(Self);
61 
63  itkTypeMacro(RingBuffer, Object);
64 
68  void SetNumberOfBuffers(SizeValueType sz);
69 
71  SizeValueType GetNumberOfBuffers();
72 
74  void MoveHead(OffsetValueType offset);
75 
77  void MoveHeadForward();
78  void MoveHeadBackward();
80 
82  bool BufferIsFull(OffsetValueType offset);
83 
86  return this->m_HeadIndex;
87  }
88 
90  typename ElementType::Pointer GetBufferContents(OffsetValueType offset);
91 
93  void SetBufferContents(OffsetValueType offset, ElementPointer element);
94 
95 protected:
96 
98  RingBuffer();
99  ~RingBuffer() override = default;
100  void PrintSelf(std::ostream &os, Indent indent) const override;
102 
104  OffsetValueType GetOffsetBufferIndex(OffsetValueType offset);
105 
109  SizeValueType m_HeadIndex{0};
110 
112  std::vector<ElementPointer> m_PointerVector;
113 }; // end RingBuffer class
114 
115 } // end namespace itk
116 
117 #ifndef ITK_MANUAL_INSTANTIATION
118 #include "itkRingBuffer.hxx"
119 #endif
120 
121 #endif
::itk::SizeValueType SizeValueType
Definition: itkRingBuffer.h:56
::itk::OffsetValueType OffsetValueType
Definition: itkRingBuffer.h:57
Light weight base class for most itk classes.
std::vector< ElementPointer > m_PointerVector
unsigned long SizeValueType
Definition: itkIntTypes.h:83
SizeValueType GetHeadIndex()
Definition: itkRingBuffer.h:85
typename ElementType::Pointer ElementPointer
Definition: itkRingBuffer.h:54
TElement ElementType
Definition: itkRingBuffer.h:53
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Base class for most ITK classes.
Definition: itkObject.h:60
Templated ring buffer for holding anything.
Definition: itkRingBuffer.h:39
signed long OffsetValueType
Definition: itkIntTypes.h:94