Go to the documentation of this file.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
00038 class ITKCommon_EXPORT DataObjectError : public ExceptionObject
00039 {
00040 public:
00043 DataObjectError();
00044
00046 virtual ~DataObjectError() throw() {}
00047
00049 DataObjectError(const char *file, unsigned int lineNumber);
00050
00052 DataObjectError(const std::string& file, unsigned int lineNumber);
00053
00055 DataObjectError(const DataObjectError &orig);
00056
00058 DataObjectError& operator=( const DataObjectError& orig);
00059
00061 itkTypeMacro(DataObjectError, ExceptionObject);
00062
00064 void SetDataObject(DataObject *dobj);
00065
00067 DataObject* GetDataObject();
00068
00069 protected:
00074 virtual void PrintSelf(std::ostream& os, Indent indent) const;
00075
00076 private:
00077 DataObject *m_DataObject;
00078 };
00079
00080
00084 class ITKCommon_EXPORT InvalidRequestedRegionError : public DataObjectError
00085 {
00086 public:
00088 InvalidRequestedRegionError();
00089
00091 virtual ~InvalidRequestedRegionError() throw() {}
00092
00094 InvalidRequestedRegionError(const char *file, unsigned int lineNumber);
00095
00097 InvalidRequestedRegionError(const std::string& file, unsigned int lineNumber);
00098
00100 InvalidRequestedRegionError(const InvalidRequestedRegionError &orig);
00101
00103 InvalidRequestedRegionError& operator=( const InvalidRequestedRegionError& orig);
00104
00106 itkTypeMacro(InvalidRequestedRegionError, DataObjectError);
00107
00108 protected:
00113 virtual void PrintSelf(std::ostream& os, Indent indent) const;
00114
00115 };
00116
00117
00118
00119
00262 class ITKCommon_EXPORT DataObject : public Object
00263 {
00264 public:
00266 typedef DataObject Self;
00267 typedef Object Superclass;
00268 typedef SmartPointer<Self> Pointer;
00269 typedef SmartPointer<const Self> ConstPointer;
00270
00272 itkTypeMacro(DataObject,Object);
00273
00279 void DisconnectPipeline();
00280
00293 SmartPointerForwardReference<ProcessObject> GetSource() const;
00294
00296 unsigned int GetSourceOutputIndex() const;
00297
00300 virtual void Initialize();
00301
00304 void SetReleaseDataFlag(bool flag)
00305 {
00306 m_ReleaseDataFlag = flag;
00307 }
00308 itkGetConstReferenceMacro(ReleaseDataFlag,bool);
00309 itkBooleanMacro(ReleaseDataFlag);
00311
00315 static void SetGlobalReleaseDataFlag(bool val);
00316 static bool GetGlobalReleaseDataFlag();
00317 static void GlobalReleaseDataFlagOn()
00318 {Self::SetGlobalReleaseDataFlag(true);}
00319 static void GlobalReleaseDataFlagOff()
00320 {Self::SetGlobalReleaseDataFlag(false);}
00322
00327 void ReleaseData();
00328
00331 bool ShouldIReleaseData() const;
00332
00334 bool GetDataReleased() const
00335 {return m_DataReleased;}
00336
00347 virtual void Update();
00348
00358 virtual void UpdateOutputInformation();
00359
00362 virtual void PropagateRequestedRegion() throw (InvalidRequestedRegionError);
00363 virtual void UpdateOutputData();
00365
00369 virtual void ResetPipeline();
00370
00373 void SetPipelineMTime(unsigned long time)
00374 {m_PipelineMTime = time;}
00375 itkGetConstReferenceMacro(PipelineMTime,unsigned long);
00377
00379 virtual unsigned long GetUpdateMTime() const;
00380
00389 virtual void PrepareForNewData()
00390 {this->Initialize();}
00391
00396 void DataHasBeenGenerated();
00397
00398
00402 virtual void SetRequestedRegionToLargestPossibleRegion() {};
00403
00413 virtual bool RequestedRegionIsOutsideOfTheBufferedRegion()
00414 { return false; }
00415
00428 virtual bool VerifyRequestedRegion() { return true; };
00429
00439 virtual void CopyInformation(const DataObject*) {};
00440
00446 virtual void SetRequestedRegion(DataObject *) {};
00447
00453 virtual void Graft( const DataObject *) {};
00454
00455 protected:
00456 DataObject();
00457 ~DataObject();
00458 void PrintSelf(std::ostream& os, Indent indent) const;
00459
00461 virtual void PropagateResetPipeline();
00462
00463 private:
00464 DataObject(const Self&);
00465 void operator=(const Self&);
00466
00468 mutable WeakPointer<ProcessObject> m_Source;
00469 mutable unsigned int m_SourceOutputIndex;
00470
00472 TimeStamp m_UpdateMTime;
00473
00474 bool m_ReleaseDataFlag;
00475 bool m_DataReleased;
00476
00479 unsigned long m_PipelineMTime;
00480
00482 static bool m_GlobalReleaseDataFlag;
00483
00488 bool ConnectSource(ProcessObject *s, unsigned long idx) const;
00489
00498 bool DisconnectSource(ProcessObject *s, unsigned long idx) const;
00499
00501 friend class ProcessObject;
00502 friend class DataObjectError;
00503 };
00504
00505 }
00506
00507 #endif
00508