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 itkTemporalDataObject_h 19 #define itkTemporalDataObject_h 20 21 #include "itkDataObject.h" 22 #include "itkRingBuffer.h" 23 #include "itkTemporalRegion.h" 24 #include "ITKVideoCoreExport.h" 25 26 namespace itk 27 { 28 29 /** \class TemporalDataObject 30 * \brief DataObject subclass with knowledge of temporal region 31 * 32 * This class represents a data object that relies on temporal regions. It uses 33 * an itk::RingBuffer to store DataObject pointers in sequential order. The 34 * pointers in the ring buffer should correspond to the BufferedTemporalRegion. 35 * The LargestPossibleTemporalRegion should indicate the maximum extent that 36 * data object is logically capable of holding, and the RequestedTemporalRegion 37 * is used in the pipeline to request that a certain temporal region be 38 * buffered 39 * 40 * \ingroup ITKVideoCore 41 */ ITK_FORCE_EXPORT_MACRO(ITKVideoCore)42class ITK_FORCE_EXPORT_MACRO(ITKVideoCore) TemporalDataObject : public DataObject 43 { 44 public: 45 ITK_DISALLOW_COPY_AND_ASSIGN(TemporalDataObject); 46 47 /** Standard class type aliases */ 48 using Self = TemporalDataObject; 49 using Superclass = DataObject; 50 using Pointer = SmartPointer< Self >; 51 using ConstPointer = SmartPointer< const Self >; 52 using ConstWeakPointer = WeakPointer< const Self >; 53 54 using BufferType = RingBuffer<DataObject>; 55 using TemporalRegionType = TemporalRegion; 56 57 /** Enum for defining the way in which to compare temporal regions */ 58 typedef enum {Frame, RealTime, FrameAndRealTime} TemporalUnitType; 59 60 itkNewMacro(Self); 61 62 /** Run-time type information (and related methods). */ 63 itkTypeMacro(TemporalDataObject, DataObject); 64 65 /** Get the type of temporal units we care about (Defaults to Frame)*/ 66 virtual TemporalUnitType GetTemporalUnit() const; 67 68 /** Explicity set temporal units (Defaults to Frame)*/ 69 virtual void SetTemporalUnitToFrame(); 70 virtual void SetTemporalUnitToRealTime(); 71 virtual void SetTemporalUnitToFrameAndRealTime(); 72 73 /** Get/Set the number of frames that the internal buffer can hold */ 74 SizeValueType GetNumberOfBuffers(); 75 void SetNumberOfBuffers(SizeValueType num); 76 77 virtual void SetLargestPossibleTemporalRegion( 78 const TemporalRegionType & region); 79 virtual const TemporalRegionType & GetLargestPossibleTemporalRegion() const; 80 81 virtual void SetBufferedTemporalRegion(const TemporalRegionType & region); 82 virtual const TemporalRegionType & GetBufferedTemporalRegion() const; 83 virtual void SetRequestedTemporalRegion(const TemporalRegionType & region); 84 virtual const TemporalRegionType & GetRequestedTemporalRegion() const; 85 86 /** Get the portion of the requested region that is not covered by the 87 * buffered region */ 88 virtual const TemporalRegionType GetUnbufferedRequestedTemporalRegion(); 89 90 void SetRequestedRegionToLargestPossibleRegion() override; 91 92 bool RequestedRegionIsOutsideOfTheBufferedRegion() override; 93 94 bool VerifyRequestedRegion() override; 95 96 void CopyInformation(const DataObject *) override; 97 98 void SetRequestedRegion(const DataObject *) override; 99 100 void Graft(const DataObject *) override; 101 102 protected: 103 104 TemporalDataObject(); 105 ~TemporalDataObject() override; 106 void PrintSelf(std::ostream & os, Indent indent) const override; 107 108 /** Buffer for holding component data objects */ 109 BufferType::Pointer m_DataObjectBuffer; 110 111 /** We want to keep track of our regions in time. **/ 112 TemporalRegionType m_LargestPossibleTemporalRegion; 113 TemporalRegionType m_RequestedTemporalRegion; 114 TemporalRegionType m_BufferedTemporalRegion; 115 116 TemporalUnitType m_TemporalUnit{Frame}; 117 }; // end class TemporalDataObject 118 119 } // end namespace itk 120 121 #endif 122