ITK  4.4.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 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();
99  void PrintSelf(std::ostream &os, Indent indent) const;
101 
103  OffsetValueType GetOffsetBufferIndex(OffsetValueType offset);
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
126