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 ITKCommon_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 ITKCommon_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
00261 class ITKCommon_EXPORT DataObject : public Object
00262 {
00263 public:
00265 typedef DataObject Self;
00266 typedef Object Superclass;
00267 typedef SmartPointer<Self> Pointer;
00268 typedef SmartPointer<const Self> ConstPointer;
00269
00271 itkTypeMacro(DataObject,Object);
00272
00278 void DisconnectPipeline();
00279
00292 SmartPointerForwardReference<ProcessObject> GetSource() const;
00293
00295 unsigned int GetSourceOutputIndex() const;
00296
00299 virtual void Initialize();
00300
00303 void SetReleaseDataFlag(bool flag)
00304 {
00305 m_ReleaseDataFlag = flag;
00306 }
00307 itkGetConstReferenceMacro(ReleaseDataFlag,bool);
00308 itkBooleanMacro(ReleaseDataFlag);
00309
00313 static void SetGlobalReleaseDataFlag(const bool val);
00314 static bool GetGlobalReleaseDataFlag();
00315 void GlobalReleaseDataFlagOn()
00316 {this->SetGlobalReleaseDataFlag(true);}
00317 void GlobalReleaseDataFlagOff()
00318 {this->SetGlobalReleaseDataFlag(false);}
00319
00324 void ReleaseData();
00325
00328 bool ShouldIReleaseData() const;
00329
00331 bool GetDataReleased() const
00332 {return m_DataReleased;}
00333
00344 virtual void Update();
00345
00355 virtual void UpdateOutputInformation();
00356
00359 virtual void PropagateRequestedRegion() throw (InvalidRequestedRegionError);
00360 virtual void UpdateOutputData();
00361
00365 virtual void ResetPipeline();
00366
00369 void SetPipelineMTime(unsigned long time)
00370 {m_PipelineMTime = time;}
00371 itkGetConstReferenceMacro(PipelineMTime,unsigned long);
00372
00374 virtual unsigned long GetUpdateMTime() const;
00375
00384 virtual void PrepareForNewData()
00385 {this->Initialize();}
00386
00391 void DataHasBeenGenerated();
00392
00393
00397 virtual void SetRequestedRegionToLargestPossibleRegion() {};
00398
00408 virtual bool RequestedRegionIsOutsideOfTheBufferedRegion()
00409 { return false; }
00410
00423 virtual bool VerifyRequestedRegion() { return true; };
00424
00434 virtual void CopyInformation(const DataObject*) {};
00435
00441 virtual void SetRequestedRegion(DataObject *) {};
00442
00448 virtual void Graft( const DataObject *) {};
00449
00450 protected:
00451 DataObject();
00452 ~DataObject();
00453 void PrintSelf(std::ostream& os, Indent indent) const;
00454
00456 virtual void PropagateResetPipeline();
00457
00458 private:
00459 DataObject(const Self&);
00460 void operator=(const Self&);
00461
00463 mutable WeakPointer<ProcessObject> m_Source;
00464 mutable unsigned int m_SourceOutputIndex;
00465
00467 TimeStamp m_UpdateMTime;
00468
00469 bool m_ReleaseDataFlag;
00470 bool m_DataReleased;
00471
00474 unsigned long m_PipelineMTime;
00475
00477 static bool m_GlobalReleaseDataFlag;
00478
00483 bool ConnectSource(ProcessObject *s, unsigned int idx) const;
00484
00493 bool DisconnectSource(ProcessObject *s, unsigned int idx) const;
00494
00496 friend class ProcessObject;
00497 friend class DataObjectError;
00498 };
00499
00500 }
00501
00502 #endif