ITK  4.13.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 // Forward reference because of private implementation
38 class SubjectImplementation;
39 // Forward reference because of circular dependencies
40 class ITK_FORWARD_EXPORT Command;
41 
59 class ITKCommon_EXPORT Object:public LightObject
60 {
61 public:
63  typedef Object Self;
67 
69  static Pointer New();
70 
76  virtual LightObject::Pointer CreateAnother() const ITK_OVERRIDE;
77 
79  itkTypeMacro(Object, LightObject);
80 
82  virtual void DebugOn() const;
83 
85  virtual void DebugOff() const;
86 
88  bool GetDebug() const;
89 
91  void SetDebug(bool debugFlag) const;
92 
94  virtual ModifiedTimeType GetMTime() const;
95 
97  virtual const TimeStamp & GetTimeStamp() const;
98 
101  virtual void Modified() const;
102 
104  virtual void Register() const ITK_OVERRIDE;
105 
107  virtual void UnRegister() const ITK_NOEXCEPT ITK_OVERRIDE;
108 
110  virtual void SetReferenceCount(int) ITK_OVERRIDE;
111 
114  static void SetGlobalWarningDisplay(bool flag);
115 
116  static bool GetGlobalWarningDisplay();
117 
118  static void GlobalWarningDisplayOn()
119  { SetGlobalWarningDisplay(true); }
121  { SetGlobalWarningDisplay(false); }
122 
131  unsigned long AddObserver(const EventObject & event, Command *);
132 
133  unsigned long AddObserver(const EventObject & event, Command *) const;
134 
140  Command * GetCommand(unsigned long tag);
141 
143  void InvokeEvent(const EventObject &);
144 
147  void InvokeEvent(const EventObject &) const;
148 
150  void RemoveObserver(unsigned long tag);
151 
153  void RemoveAllObservers();
154 
156  bool HasObserver(const EventObject & event) const;
157 
162  MetaDataDictionary & GetMetaDataDictionary();
163 
167  const MetaDataDictionary & GetMetaDataDictionary() const;
168 
172  void SetMetaDataDictionary(const MetaDataDictionary & rhs);
173 
181  itkSetMacro(ObjectName, std::string);
182  itkGetConstReferenceMacro(ObjectName, std::string);
184 
185 protected:
186  Object();
187  virtual ~Object() ITK_OVERRIDE;
188 
193  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
194 
195  bool PrintObservers(std::ostream & os, Indent indent) const;
196 
200  virtual void SetTimeStamp( const TimeStamp & time );
201 
202 private:
203  ITK_DISALLOW_COPY_AND_ASSIGN(Object);
204 
206  mutable bool m_Debug;
207 
209  mutable TimeStamp m_MTime;
210 
212  static bool m_GlobalWarningDisplay;
213 
216  SubjectImplementation *m_SubjectImplementation;
217 
225  mutable MetaDataDictionary *m_MetaDataDictionary;
226 
227  std::string m_ObjectName;
228 };
229 } // end namespace itk
230 
231 #endif
Light weight base class for most itk classes.
unsigned long ModifiedTimeType
Definition: itkIntTypes.h:164
LightObject Superclass
Definition: itkObject.h:64
Provides a mechanism for storing a collection of arbitrary data types.
Object Self
Definition: itkObject.h:63
SmartPointer< Self > Pointer
Definition: itkObject.h:65
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:59
Abstraction of the Events used to communicating among filters and with GUIs.
SmartPointer< const Self > ConstPointer
Definition: itkObject.h:66
Control indentation during Print() invocation.
Definition: itkIndent.h:49
static void GlobalWarningDisplayOff()
Definition: itkObject.h:120
Base class for most ITK classes.
Definition: itkObject.h:59
Superclass for callback/observer methods.
Definition: itkCommand.h:44