Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkDataObject.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkDataObject.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/12/03 13:42:08 $
00007   Version:   $Revision: 1.67 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012   Portions of this code are covered under the VTK copyright.
00013   See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details.
00014 
00015      This software is distributed WITHOUT ANY WARRANTY; without even 
00016      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00017      PURPOSE.  See the above copyright notices for more information.
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 /*--------------------Data Object Exceptions---------------------------*/
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:
00086 
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 /*----------------------------Data Object--------------------------------*/  
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(const bool val);
00316   static bool GetGlobalReleaseDataFlag();
00317   void GlobalReleaseDataFlagOn() 
00318     {this->SetGlobalReleaseDataFlag(true);}
00319   void GlobalReleaseDataFlagOff() 
00320     {this->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&); //purposely not implemented
00465   void operator=(const Self&); //purposely not implemented
00466 
00468   mutable WeakPointer<ProcessObject> m_Source; 
00469   mutable unsigned int m_SourceOutputIndex;
00470 
00472   TimeStamp m_UpdateMTime;  
00473 
00474   bool m_ReleaseDataFlag; //Data will release after use by a filter if on
00475   bool m_DataReleased; //Keep track of data release during pipeline execution
00476 
00479   unsigned long m_PipelineMTime;
00480 
00482   static bool m_GlobalReleaseDataFlag;
00483 
00488   bool ConnectSource(ProcessObject *s, unsigned int idx) const;
00489 
00498   bool DisconnectSource(ProcessObject *s, unsigned int idx) const;
00499 
00501   friend class ProcessObject;
00502   friend class DataObjectError;
00503   };
00504 
00505 } // end namespace itk
00506   
00507 #endif
00508 

Generated at Sun Sep 23 12:20:47 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000