ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkObject.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 /*=========================================================================
19  *
20  * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21  *
22  * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23  *
24  * For complete copyright, license and disclaimer of warranty information
25  * please refer to the NOTICE file at the top of the ITK source tree.
26  *
27  *=========================================================================*/
28 #ifndef __itkObject_h
29 #define __itkObject_h
30 
31 #include "itkLightObject.h"
32 #include "itkEventObject.h"
33 #include "itkMetaDataDictionary.h"
34 
35 namespace itk
36 {
37 class SubjectImplementation;
38 class Command;
39 
57 class ITKCommon_EXPORT Object:public LightObject
58 {
59 public:
61  typedef Object Self;
65 
67  static Pointer New();
68 
74  virtual LightObject::Pointer CreateAnother() const;
75 
77  itkTypeMacro(Object, LightObject);
78 
80  virtual void DebugOn() const;
81 
83  virtual void DebugOff() const;
84 
86  bool GetDebug() const;
87 
89  void SetDebug(bool debugFlag) const;
90 
92  virtual ModifiedTimeType GetMTime() const;
93 
95  virtual const TimeStamp & GetTimeStamp() const;
96 
99  virtual void Modified() const;
100 
102  virtual void Register() const;
103 
105  virtual void UnRegister() const;
106 
108  virtual void SetReferenceCount(int);
109 
112  static void SetGlobalWarningDisplay(bool flag);
113 
114  static bool GetGlobalWarningDisplay();
115 
116  static void GlobalWarningDisplayOn()
117  { SetGlobalWarningDisplay(true); }
118  static void GlobalWarningDisplayOff()
119  { SetGlobalWarningDisplay(false); }
120 
129  unsigned long AddObserver(const EventObject & event, Command *);
130 
131  unsigned long AddObserver(const EventObject & event, Command *) const;
132 
138  Command * GetCommand(unsigned long tag);
139 
141  void InvokeEvent(const EventObject &);
142 
145  void InvokeEvent(const EventObject &) const;
146 
148  void RemoveObserver(unsigned long tag);
149 
151  void RemoveAllObservers();
152 
154  bool HasObserver(const EventObject & event) const;
155 
160  MetaDataDictionary & GetMetaDataDictionary(void);
161 
165  const MetaDataDictionary & GetMetaDataDictionary(void) const;
166 
170  void SetMetaDataDictionary(const MetaDataDictionary & rhs);
171 
172 protected:
173  Object();
174  virtual ~Object();
175 
180  virtual void PrintSelf(std::ostream & os, Indent indent) const;
181 
182  bool PrintObservers(std::ostream & os, Indent indent) const;
183 
187  virtual void SetTimeStamp( const TimeStamp & time );
188 
189 private:
190  Object(const Self &); //purposely not implemented
191  void operator=(const Self &); //purposely not implemented
192 
194  mutable bool m_Debug;
195 
198 
201 
204  SubjectImplementation *m_SubjectImplementation;
205 
214 };
215 } // end namespace itk
216 
217 #endif
218