ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkRingBuffer_h 00019 #define __itkRingBuffer_h 00020 00021 #include "itkObject.h" 00022 #include "itkObjectFactory.h" 00023 #include "itkIntTypes.h" 00024 00025 namespace itk 00026 { 00038 template< class TElement > 00039 class ITK_EXPORT RingBuffer : public Object 00040 { 00041 00042 public: 00043 00047 typedef RingBuffer Self; 00048 typedef Object Superclass; 00049 typedef SmartPointer< Self > Pointer; 00050 typedef SmartPointer< const Self > ConstPointer; 00051 00053 typedef TElement ElementType; 00054 typedef typename ElementType::Pointer ElementPointer; 00055 00056 typedef ::itk::SizeValueType SizeValueType; 00057 typedef ::itk::OffsetValueType OffsetValueType; 00058 00060 itkNewMacro(Self); 00061 00063 itkTypeMacro(RingBuffer, Object); 00064 00068 void SetNumberOfBuffers(SizeValueType sz); 00069 00071 SizeValueType GetNumberOfBuffers(); 00072 00074 void MoveHead(OffsetValueType offset); 00075 00077 void MoveHeadForward(); 00078 void MoveHeadBackward(); 00080 00082 bool BufferIsFull(OffsetValueType offset); 00083 00085 SizeValueType GetHeadIndex() { 00086 return this->m_HeadIndex; 00087 } 00088 00090 typename ElementType::Pointer GetBufferContents(OffsetValueType offset); 00091 00093 void SetBufferContents(OffsetValueType offset, ElementPointer element); 00094 00095 protected: 00096 00098 RingBuffer(); 00099 virtual ~RingBuffer(); 00100 void PrintSelf(std::ostream &os, Indent indent) const; 00102 00104 OffsetValueType GetOffsetBufferIndex(OffsetValueType offset); 00105 00109 SizeValueType m_HeadIndex; 00110 00112 std::vector<ElementPointer> m_PointerVector; 00113 private: 00114 RingBuffer(const Self &); // purposely not implemented 00115 void operator=(const Self &); // purposely not implemented 00117 00118 }; // end RingBuffer class 00119 00120 } // end namespace itk 00121 00122 #if ITK_TEMPLATE_TXX 00123 #include "itkRingBuffer.hxx" 00124 #endif 00125 00126 #endif 00127