ITK  5.2.0
Insight Toolkit
itkRingBuffer.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 {
39 template <typename TElement>
40 class ITK_TEMPLATE_EXPORT RingBuffer : public Object
41 {
42 public:
43  ITK_DISALLOW_COPY_AND_ASSIGN(RingBuffer);
44 
48  using Self = RingBuffer;
49  using Superclass = Object;
52 
54  using ElementType = TElement;
55  using ElementPointer = typename ElementType::Pointer;
56 
59 
61  itkNewMacro(Self);
62 
64  itkTypeMacro(RingBuffer, Object);
65 
69  void
70  SetNumberOfBuffers(SizeValueType sz);
71 
74  GetNumberOfBuffers();
75 
77  void
78  MoveHead(OffsetValueType offset);
79 
81  void
82  MoveHeadForward();
83  void
84  MoveHeadBackward();
86 
88  bool
89  BufferIsFull(OffsetValueType offset);
90 
94  {
95  return this->m_HeadIndex;
96  }
97 
99  typename ElementType::Pointer
100  GetBufferContents(OffsetValueType offset);
101 
103  void
104  SetBufferContents(OffsetValueType offset, ElementPointer element);
105 
106 protected:
108  RingBuffer();
109  ~RingBuffer() override = default;
110  void
111  PrintSelf(std::ostream & os, Indent indent) const override;
113 
116  GetOffsetBufferIndex(OffsetValueType offset);
117 
121  SizeValueType m_HeadIndex{ 0 };
122 
124  std::vector<ElementPointer> m_PointerVector;
125 }; // end RingBuffer class
126 
127 } // end namespace itk
128 
129 #ifndef ITK_MANUAL_INSTANTIATION
130 # include "itkRingBuffer.hxx"
131 #endif
132 
133 #endif
itkObjectFactory.h
itk::RingBuffer::SizeValueType
::itk::SizeValueType SizeValueType
Definition: itkRingBuffer.h:57
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::RingBuffer::OffsetValueType
::itk::OffsetValueType OffsetValueType
Definition: itkRingBuffer.h:58
itk::RingBuffer::ElementType
TElement ElementType
Definition: itkRingBuffer.h:54
itk::RingBuffer::ElementPointer
typename ElementType::Pointer ElementPointer
Definition: itkRingBuffer.h:55
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::RingBuffer::m_PointerVector
std::vector< ElementPointer > m_PointerVector
Definition: itkRingBuffer.h:124
itk::RingBuffer
Templated ring buffer for holding anything.
Definition: itkRingBuffer.h:40
itkIntTypes.h
itkObject.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::OffsetValueType
signed long OffsetValueType
Definition: itkIntTypes.h:94
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:62
itk::RingBuffer::GetHeadIndex
SizeValueType GetHeadIndex()
Definition: itkRingBuffer.h:93
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83