ITK  5.1.0
Insight Toolkit
itkObject.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 #include "itkSingletonMacro.h"
35 
36 namespace itk
37 {
38 // Forward reference because of private implementation
39 class SubjectImplementation;
40 // Forward reference because of circular dependencies
41 class ITK_FORWARD_EXPORT Command;
42 
60 class ITKCommon_EXPORT Object : public LightObject
61 {
62 public:
63  ITK_DISALLOW_COPY_AND_ASSIGN(Object);
64 
66  using Self = Object;
70 
72  static Pointer
73  New();
74 
81  CreateAnother() const override;
82 
84  itkTypeMacro(Object, LightObject);
85 
87  virtual void
88  DebugOn() const;
89 
91  virtual void
92  DebugOff() const;
93 
95  bool
96  GetDebug() const;
97 
99  void
100  SetDebug(bool debugFlag) const;
101 
103  virtual ModifiedTimeType
104  GetMTime() const;
105 
107  virtual const TimeStamp &
108  GetTimeStamp() const;
109 
112  virtual void
113  Modified() const;
114 
116  void
117  Register() const override;
118 
120  void
121  UnRegister() const noexcept override;
122 
124  void
125  SetReferenceCount(int) override;
126 
129  static void
130  SetGlobalWarningDisplay(bool flag);
131 
132  static bool
133  GetGlobalWarningDisplay();
134 
135  static void
136  GlobalWarningDisplayOn()
137  {
138  SetGlobalWarningDisplay(true);
139  }
140  static void
142  {
143  SetGlobalWarningDisplay(false);
144  }
145 
154  unsigned long
155  AddObserver(const EventObject & event, Command *);
156 
157  unsigned long
158  AddObserver(const EventObject & event, Command *) const;
159 
165  Command *
166  GetCommand(unsigned long tag);
167 
169  void
170  InvokeEvent(const EventObject &);
171 
174  void
175  InvokeEvent(const EventObject &) const;
176 
178  void
179  RemoveObserver(unsigned long tag);
180 
182  void
183  RemoveAllObservers();
184 
186  bool
187  HasObserver(const EventObject & event) const;
188 
194  GetMetaDataDictionary();
195 
199  const MetaDataDictionary &
200  GetMetaDataDictionary() const;
201 
205  void
206  SetMetaDataDictionary(const MetaDataDictionary & rhs);
207  void
208  SetMetaDataDictionary(MetaDataDictionary && rrhs);
210 
218  itkSetMacro(ObjectName, std::string);
219  itkGetConstReferenceMacro(ObjectName, std::string);
221 
222 protected:
223  Object();
224  ~Object() override;
225 
230  void
231  PrintSelf(std::ostream & os, Indent indent) const override;
232 
233  bool
234  PrintObservers(std::ostream & os, Indent indent) const;
235 
239  virtual void
240  SetTimeStamp(const TimeStamp & time);
241 
242 private:
244  itkGetGlobalDeclarationMacro(bool, GlobalWarningDisplay);
245 
247  mutable bool m_Debug{ false };
248 
251 
253  static bool * m_GlobalWarningDisplay;
254 
257  SubjectImplementation * m_SubjectImplementation{ nullptr };
258 
266  mutable MetaDataDictionary * m_MetaDataDictionary{ nullptr };
267 
268  std::string m_ObjectName;
269 };
270 } // end namespace itk
271 
272 #endif
itk::Object::GlobalWarningDisplayOff
static void GlobalWarningDisplayOff()
Definition: itkObject.h:141
itk::ModifiedTimeType
SizeValueType ModifiedTimeType
Definition: itkIntTypes.h:102
itkSingletonMacro.h
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::Object::m_GlobalWarningDisplay
static bool * m_GlobalWarningDisplay
Definition: itkObject.h:253
itk::Command
Superclass for callback/observer methods.
Definition: itkCommand.h:44
itk::MetaDataDictionary
Provides a mechanism for storing a collection of arbitrary data types.
Definition: itkMetaDataDictionary.h:53
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::Object::m_ObjectName
std::string m_ObjectName
Definition: itkObject.h:268
itk::TimeStamp
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:60
itkMetaDataDictionary.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::Object::m_MTime
TimeStamp m_MTime
Definition: itkObject.h:250
itkGetGlobalDeclarationMacro
#define itkGetGlobalDeclarationMacro(Type, VarName)
Definition: itkSingletonMacro.h:34
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:60
itk::EventObject
Abstraction of the Events used to communicating among filters and with GUIs.
Definition: itkEventObject.h:57
itkEventObject.h
itkLightObject.h