ITK  4.2.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< class TElement >
39 class ITK_EXPORT RingBuffer : public Object
40 {
41 
42 public:
43 
47  typedef RingBuffer Self;
48  typedef Object Superclass;
51 
53  typedef TElement ElementType;
54  typedef typename ElementType::Pointer ElementPointer;
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  virtual ~RingBuffer();
100  void PrintSelf(std::ostream &os, Indent indent) const;
102 
104  OffsetValueType GetOffsetBufferIndex(OffsetValueType offset);
105 
110 
112  std::vector<ElementPointer> m_PointerVector;
113 private:
114  RingBuffer(const Self &); // purposely not implemented
115  void operator=(const Self &); // purposely not implemented
117 
118 }; // end RingBuffer class
119 
120 } // end namespace itk
121 
122 #if ITK_TEMPLATE_TXX
123 #include "itkRingBuffer.hxx"
124 #endif
125 
126 #endif
127