ITK  4.8.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 ITK_OVERRIDE;
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 ITK_OVERRIDE;
103 
105  virtual void UnRegister() const ITK_NOEXCEPT ITK_OVERRIDE;
106 
108  virtual void SetReferenceCount(int) ITK_OVERRIDE;
109 
112  static void SetGlobalWarningDisplay(bool flag);
113 
114  static bool GetGlobalWarningDisplay();
115 
116  static void GlobalWarningDisplayOn()
117  { SetGlobalWarningDisplay(true); }
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();
161 
165  const MetaDataDictionary & GetMetaDataDictionary() const;
166 
170  void SetMetaDataDictionary(const MetaDataDictionary & rhs);
171 
179  itkSetMacro(ObjectName, std::string);
180  itkGetConstReferenceMacro(ObjectName, std::string);
182 
183 protected:
184  Object();
185  virtual ~Object();
186 
191  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
192 
193  bool PrintObservers(std::ostream & os, Indent indent) const;
194 
198  virtual void SetTimeStamp( const TimeStamp & time );
199 
200 private:
201  Object(const Self &); //purposely not implemented
202  void operator=(const Self &); //purposely not implemented
203 
205  mutable bool m_Debug;
206 
209 
212 
215  SubjectImplementation *m_SubjectImplementation;
216 
225 
226  std::string m_ObjectName;
227 };
228 } // end namespace itk
229 
230 #endif
MetaDataDictionary * m_MetaDataDictionary
Definition: itkObject.h:224
bool m_Debug
Definition: itkObject.h:205
Light weight base class for most itk classes.
unsigned long ModifiedTimeType
Definition: itkIntTypes.h:164
static bool m_GlobalWarningDisplay
Definition: itkObject.h:211
LightObject Superclass
Definition: itkObject.h:62
Provides a mechanism for storing a collection of arbitrary data types.
TimeStamp m_MTime
Definition: itkObject.h:208
Object Self
Definition: itkObject.h:61
SmartPointer< Self > Pointer
Definition: itkObject.h:63
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:58
std::string m_ObjectName
Definition: itkObject.h:226
Abstraction of the Events used to communicating among filters and with GUIs.
SmartPointer< const Self > ConstPointer
Definition: itkObject.h:64
SubjectImplementation * m_SubjectImplementation
Definition: itkObject.h:215
Control indentation during Print() invocation.
Definition: itkIndent.h:49
static void GlobalWarningDisplayOff()
Definition: itkObject.h:118
Base class for most ITK classes.
Definition: itkObject.h:57
Superclass for callback/observer methods.
Definition: itkCommand.h:44