ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkObject.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 /*=========================================================================
00019  *
00020  *  Portions of this file are subject to the VTK Toolkit Version 3 copyright.
00021  *
00022  *  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00023  *
00024  *  For complete copyright, license and disclaimer of warranty information
00025  *  please refer to the NOTICE file at the top of the ITK source tree.
00026  *
00027  *=========================================================================*/
00028 #ifndef __itkObject_h
00029 #define __itkObject_h
00030 
00031 #include "itkLightObject.h"
00032 #include "itkEventObject.h"
00033 #include "itkMetaDataDictionary.h"
00034 
00035 namespace itk
00036 {
00037 class SubjectImplementation;
00038 class Command;
00039 
00057 class ITKCommon_EXPORT Object:public LightObject
00058 {
00059 public:
00061   typedef Object                     Self;
00062   typedef LightObject                Superclass;
00063   typedef SmartPointer< Self >       Pointer;
00064   typedef SmartPointer< const Self > ConstPointer;
00065 
00067   static Pointer New();
00068 
00074   virtual LightObject::Pointer CreateAnother() const;
00075 
00077   itkTypeMacro(Object, LightObject);
00078 
00080   virtual void DebugOn() const;
00081 
00083   virtual void DebugOff() const;
00084 
00086   bool GetDebug() const;
00087 
00089   void SetDebug(bool debugFlag) const;
00090 
00092   virtual unsigned long GetMTime() const;
00093 
00095   virtual const TimeStamp & GetTimeStamp() const;
00096 
00099   virtual void Modified() const;
00100 
00102   virtual void Register() const;
00103 
00105   virtual void UnRegister() const;
00106 
00108   virtual void SetReferenceCount(int);
00109 
00112   static void SetGlobalWarningDisplay(bool flag);
00113 
00114   static bool GetGlobalWarningDisplay();
00115 
00116   static void GlobalWarningDisplayOn()
00117   { SetGlobalWarningDisplay(true); }
00118   static void GlobalWarningDisplayOff()
00119   { SetGlobalWarningDisplay(false); }
00120 
00129   unsigned long AddObserver(const EventObject & event, Command *);
00130 
00131   unsigned long AddObserver(const EventObject & event, Command *) const;
00132 
00138   Command * GetCommand(unsigned long tag);
00139 
00141   void InvokeEvent(const EventObject &);
00142 
00145   void InvokeEvent(const EventObject &) const;
00146 
00148   void RemoveObserver(unsigned long tag);
00149 
00151   void RemoveAllObservers();
00152 
00154   bool HasObserver(const EventObject & event) const;
00155 
00160   MetaDataDictionary & GetMetaDataDictionary(void);
00161 
00165   const MetaDataDictionary & GetMetaDataDictionary(void) const;
00166 
00170   void SetMetaDataDictionary(const MetaDataDictionary & rhs);
00171 
00172 protected:
00173   Object();
00174   virtual ~Object();
00175 
00180   virtual void PrintSelf(std::ostream & os, Indent indent) const;
00181 
00182   bool PrintObservers(std::ostream & os, Indent indent) const;
00183 
00187   virtual void SetTimeStamp( const TimeStamp & time );
00188 
00189 private:
00190   Object(const Self &);         //purposely not implemented
00191   void operator=(const Self &); //purposely not implemented
00192 
00194   mutable bool m_Debug;
00195 
00197   mutable TimeStamp m_MTime;
00198 
00200   static bool m_GlobalWarningDisplay;
00201 
00204   SubjectImplementation *m_SubjectImplementation;
00205 
00213   mutable MetaDataDictionary *m_MetaDataDictionary;
00214 };
00215 } // end namespace itk
00216 
00217 #endif
00218