ITK  4.6.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 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 
68 
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();
99  virtual void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE;
101 
104 
109 
111  std::vector<ElementPointer> m_PointerVector;
112 
113 private:
114  RingBuffer(const Self &); // purposely not implemented
115  void operator=(const Self &); // purposely not implemented
116 
117 }; // end RingBuffer class
118 
119 } // end namespace itk
120 
121 #ifndef ITK_MANUAL_INSTANTIATION
122 #include "itkRingBuffer.hxx"
123 #endif
124 
125 #endif
void SetBufferContents(OffsetValueType offset, ElementPointer element)
::itk::SizeValueType SizeValueType
Definition: itkRingBuffer.h:55
void MoveHeadForward()
Light weight base class for most itk classes.
void MoveHead(OffsetValueType offset)
std::vector< ElementPointer > m_PointerVector
signed long OffsetValueType
Definition: itkIntTypes.h:154
void SetNumberOfBuffers(SizeValueType sz)
void operator=(const Self &)
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
ElementType::Pointer GetBufferContents(OffsetValueType offset)
TElement ElementType
Definition: itkRingBuffer.h:52
SizeValueType GetNumberOfBuffers()
SizeValueType m_HeadIndex
bool BufferIsFull(OffsetValueType offset)
OffsetValueType GetOffsetBufferIndex(OffsetValueType offset)
SmartPointer< const Self > ConstPointer
Definition: itkRingBuffer.h:49
RingBuffer Self
Definition: itkRingBuffer.h:46
virtual ~RingBuffer()
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
Base class for most ITK classes.
Definition: itkObject.h:57
Templated ring buffer for holding anything.
Definition: itkRingBuffer.h:39
void MoveHeadBackward()