ITK  4.13.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 
46  typedef RingBuffer Self;
47  typedef Object Superclass;
50 
52  typedef TElement ElementType;
53  typedef typename ElementType::Pointer ElementPointer;
54 
57 
59  itkNewMacro(Self);
60 
62  itkTypeMacro(RingBuffer, Object);
63 
67  void SetNumberOfBuffers(SizeValueType sz);
68 
70  SizeValueType GetNumberOfBuffers();
71 
73  void MoveHead(OffsetValueType offset);
74 
76  void MoveHeadForward();
77  void MoveHeadBackward();
79 
81  bool BufferIsFull(OffsetValueType offset);
82 
85  return this->m_HeadIndex;
86  }
87 
89  typename ElementType::Pointer GetBufferContents(OffsetValueType offset);
90 
92  void SetBufferContents(OffsetValueType offset, ElementPointer element);
93 
94 protected:
95 
97  RingBuffer();
98  virtual ~RingBuffer() ITK_OVERRIDE;
99  virtual void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE;
101 
103  OffsetValueType GetOffsetBufferIndex(OffsetValueType offset);
104 
108  SizeValueType m_HeadIndex;
109 
111  std::vector<ElementPointer> m_PointerVector;
112 
113 private:
114  ITK_DISALLOW_COPY_AND_ASSIGN(RingBuffer);
115 
116 }; // end RingBuffer class
117 
118 } // end namespace itk
119 
120 #ifndef ITK_MANUAL_INSTANTIATION
121 #include "itkRingBuffer.hxx"
122 #endif
123 
124 #endif
::itk::SizeValueType SizeValueType
Definition: itkRingBuffer.h:55
Light weight base class for most itk classes.
signed long OffsetValueType
Definition: itkIntTypes.h:154
SizeValueType GetHeadIndex()
Definition: itkRingBuffer.h:84
SmartPointer< Self > Pointer
Definition: itkRingBuffer.h:48
::itk::OffsetValueType OffsetValueType
Definition: itkRingBuffer.h:56
unsigned long SizeValueType
Definition: itkIntTypes.h:143
ElementType::Pointer ElementPointer
Definition: itkRingBuffer.h:53
TElement ElementType
Definition: itkRingBuffer.h:52
SmartPointer< const Self > ConstPointer
Definition: itkRingBuffer.h:49
RingBuffer Self
Definition: itkRingBuffer.h:46
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Base class for most ITK classes.
Definition: itkObject.h:59
Templated ring buffer for holding anything.
Definition: itkRingBuffer.h:39