ITK  5.0.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 #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 New();
73 
79  LightObject::Pointer CreateAnother() const override;
80 
82  itkTypeMacro(Object, LightObject);
83 
85  virtual void DebugOn() const;
86 
88  virtual void DebugOff() const;
89 
91  bool GetDebug() const;
92 
94  void SetDebug(bool debugFlag) const;
95 
97  virtual ModifiedTimeType GetMTime() const;
98 
100  virtual const TimeStamp & GetTimeStamp() const;
101 
104  virtual void Modified() const;
105 
107  void Register() const override;
108 
110  void UnRegister() const noexcept override;
111 
113  void SetReferenceCount(int) override;
114 
117  static void SetGlobalWarningDisplay(bool flag);
118 
119  static bool GetGlobalWarningDisplay();
120 
121  static void GlobalWarningDisplayOn()
122  { SetGlobalWarningDisplay(true); }
124  { SetGlobalWarningDisplay(false); }
125 
134  unsigned long AddObserver(const EventObject & event, Command *);
135 
136  unsigned long AddObserver(const EventObject & event, Command *) const;
137 
143  Command * GetCommand(unsigned long tag);
144 
146  void InvokeEvent(const EventObject &);
147 
150  void InvokeEvent(const EventObject &) const;
151 
153  void RemoveObserver(unsigned long tag);
154 
156  void RemoveAllObservers();
157 
159  bool HasObserver(const EventObject & event) const;
160 
165  MetaDataDictionary & GetMetaDataDictionary();
166 
170  const MetaDataDictionary & GetMetaDataDictionary() const;
171 
175  void SetMetaDataDictionary(const MetaDataDictionary & rhs);
176  void SetMetaDataDictionary( MetaDataDictionary && rrhs);
178 
186  itkSetMacro(ObjectName, std::string);
187  itkGetConstReferenceMacro(ObjectName, std::string);
189 
190 protected:
191  Object();
192  ~Object() override;
193 
198  void PrintSelf(std::ostream & os, Indent indent) const override;
199 
200  bool PrintObservers(std::ostream & os, Indent indent) const;
201 
205  virtual void SetTimeStamp( const TimeStamp & time );
206 
207 private:
209  itkGetGlobalDeclarationMacro(bool, GlobalWarningDisplay);
210 
212  mutable bool m_Debug{false};
213 
216 
219 
222  SubjectImplementation *m_SubjectImplementation{nullptr};
223 
231  mutable MetaDataDictionary *m_MetaDataDictionary{nullptr};
232 
233  std::string m_ObjectName;
234 };
235 } // end namespace itk
236 
237 #endif
Light weight base class for most itk classes.
#define itkGetGlobalDeclarationMacro(Type, VarName)
Provides a mechanism for storing a collection of arbitrary data types.
TimeStamp m_MTime
Definition: itkObject.h:215
static bool * m_GlobalWarningDisplay
Definition: itkObject.h:218
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:60
unsigned long ModifiedTimeType
Definition: itkIntTypes.h:104
std::string m_ObjectName
Definition: itkObject.h:233
Abstraction of the Events used to communicating among filters and with GUIs.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
static void GlobalWarningDisplayOff()
Definition: itkObject.h:123
Base class for most ITK classes.
Definition: itkObject.h:60
Superclass for callback/observer methods.
Definition: itkCommand.h:44