00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __itkDataObject_h
00021 #define __itkDataObject_h
00022
00023 #include "itkObject.h"
00024 #include "itkSmartPointerForwardReference.h"
00025 #include "itkWeakPointer.h"
00026 #include "itkExceptionObject.h"
00027
00028 namespace itk
00029 {
00030
00031 class ProcessObject;
00032 class DataObject;
00033
00034
00035
00037 class ITK_EXPORT DataObjectError : public ExceptionObject
00038 {
00039 public:
00042 DataObjectError();
00043
00045 virtual ~DataObjectError() throw() {}
00046
00048 DataObjectError(const char *file, unsigned int lineNumber);
00049
00051 DataObjectError(const std::string& file, unsigned int lineNumber);
00052
00054 DataObjectError(const DataObjectError &orig);
00055
00057 DataObjectError& operator=( const DataObjectError& orig);
00058
00060 itkTypeMacro(DataObjectError, ExceptionObject);
00061
00063 void SetDataObject(DataObject *dobj);
00064
00066 DataObject* GetDataObject();
00067
00068 protected:
00073 virtual void PrintSelf(std::ostream& os, Indent indent) const;
00074
00075 private:
00076 DataObject *m_DataObject;
00077 };
00078
00079
00083 class ITK_EXPORT InvalidRequestedRegionError : public DataObjectError
00084 {
00085 public:
00087 InvalidRequestedRegionError();
00088
00090 virtual ~InvalidRequestedRegionError() throw() {}
00091
00093 InvalidRequestedRegionError(const char *file, unsigned int lineNumber);
00094
00096 InvalidRequestedRegionError(const std::string& file, unsigned int lineNumber);
00097
00099 InvalidRequestedRegionError(const InvalidRequestedRegionError &orig);
00100
00102 InvalidRequestedRegionError& operator=( const InvalidRequestedRegionError& orig);
00103
00105 itkTypeMacro(InvalidRequestedRegionError, DataObjectError);
00106
00107 protected:
00112 virtual void PrintSelf(std::ostream& os, Indent indent) const;
00113
00114 };
00115
00116
00117
00118
00135 class ITK_EXPORT DataObject : public Object
00136 {
00137 public:
00139 typedef DataObject Self;
00140 typedef Object Superclass;
00141 typedef SmartPointer<Self> Pointer;
00142 typedef SmartPointer<const Self> ConstPointer;
00143
00145 itkTypeMacro(DataObject,Object);
00146
00152 void DisconnectPipeline() const;
00153
00166 SmartPointerForwardReference<ProcessObject> GetSource() const;
00167
00169 unsigned int GetSourceOutputIndex() const;
00170
00173 virtual void Initialize();
00174
00177 itkSetMacro(ReleaseDataFlag,bool);
00178 itkGetMacro(ReleaseDataFlag,bool);
00179 itkBooleanMacro(ReleaseDataFlag);
00180
00184 static void SetGlobalReleaseDataFlag(const bool val);
00185 static bool GetGlobalReleaseDataFlag();
00186 void GlobalReleaseDataFlagOn()
00187 {this->SetGlobalReleaseDataFlag(true);}
00188 void GlobalReleaseDataFlagOff()
00189 {this->SetGlobalReleaseDataFlag(false);}
00190
00195 void ReleaseData();
00196
00199 bool ShouldIReleaseData() const;
00200
00202 bool GetDataReleased() const
00203 {return m_DataReleased;}
00204
00215 virtual void Update();
00216
00225 virtual void UpdateOutputInformation() = 0;
00226
00228 virtual void PropagateRequestedRegion() throw (InvalidRequestedRegionError);
00229 virtual void UpdateOutputData();
00230
00234 virtual void ResetPipeline();
00235
00237 void SetPipelineMTime(unsigned long time)
00238 {m_PipelineMTime = time;}
00239 itkGetConstMacro(PipelineMTime,unsigned long);
00240
00249 virtual void PrepareForNewData()
00250 {this->Initialize();}
00251
00256 void DataHasBeenGenerated();
00257
00261 void ComputeEstimatedPipelineMemorySize(unsigned long sizes[3]);
00262 unsigned long GetEstimatedPipelineMemorySize();
00263 virtual unsigned long GetEstimatedMemorySize();
00264 virtual unsigned long GetActualMemorySize();
00265
00269 virtual void SetRequestedRegionToLargestPossibleRegion() = 0;
00270
00280 virtual bool RequestedRegionIsOutsideOfTheBufferedRegion() = 0;
00281
00292 virtual bool VerifyRequestedRegion() = 0;
00293
00303 virtual void CopyInformation(const DataObject*) {};
00304
00308 virtual void SetRequestedRegion(DataObject *data) = 0;
00309
00310 protected:
00311 DataObject();
00312 ~DataObject();
00313 void PrintSelf(std::ostream& os, Indent indent) const;
00314
00316 virtual void PropagateResetPipeline();
00317
00318
00319 bool m_LastRequestedRegionWasOutsideOfTheBufferedRegion;
00320
00321
00322
00323 bool m_RequestedRegionInitialized;
00324
00325 private:
00326 DataObject(const Self&);
00327 void operator=(const Self&);
00328
00330 mutable WeakPointer<ProcessObject> m_Source;
00331 mutable unsigned int m_SourceOutputIndex;
00332
00334 TimeStamp m_UpdateTime;
00335
00336 bool m_ReleaseDataFlag;
00337 bool m_DataReleased;
00338
00341 unsigned long m_PipelineMTime;
00342
00345 unsigned long m_EstimatedWholeMemorySize;
00346
00348 static bool m_GlobalReleaseDataFlag;
00349
00354 void ConnectSource(ProcessObject *s, unsigned int idx) const;
00355
00364 void DisconnectSource(ProcessObject *s, unsigned int idx) const;
00365
00367 friend class ProcessObject;
00368 friend class DataObjectError;
00369 };
00370
00371 }
00372
00373 #endif