ITK  5.4.0
Insight Toolkit
itkLightObject.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  * https://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 #ifndef itkLightObject_h
19 #define itkLightObject_h
20 
21 #include "itkMacro.h"
22 #include "itkSmartPointer.h"
23 #include "itkTimeStamp.h"
24 #include "itkIndent.h"
25 #include <atomic>
26 
27 #include <iostream>
28 #include <typeinfo>
29 
30 #if defined(_WIN32)
31 # include "itkWindows.h"
32 #endif
33 
34 namespace itk
35 {
55 class ITKCommon_EXPORT LightObject
56 {
57 public:
58  ITK_DISALLOW_COPY_AND_MOVE(LightObject);
59 
61  using Self = LightObject;
64 
66  static Pointer
67  New();
68 
74  virtual Pointer
75  CreateAnother() const;
76 
78  Pointer
79  Clone() const
80  {
81  return this->InternalClone();
82  }
83 
87  virtual void
88  Delete();
89 
93  virtual const char *
94  GetNameOfClass() const;
95 
96 #ifdef _WIN32
97 
98  void * operator new(size_t);
99 
100  void * operator new[](size_t);
101 
102  void
103  operator delete(void *);
104 
105  void
106  operator delete[](void *, size_t);
107 
108 #endif
109 
111  void
112  Print(std::ostream & os, Indent indent = 0) const;
113 
116  static void
117  BreakOnError();
118 
120  virtual void
121  Register() const;
122 
124  virtual void
125  UnRegister() const noexcept;
126 
128  virtual int
129  GetReferenceCount() const
130  {
131  return m_ReferenceCount;
132  }
133 
136  virtual void
137  SetReferenceCount(int);
138 
139 protected:
140  LightObject();
141  virtual ~LightObject();
142 
147  virtual void
148  PrintSelf(std::ostream & os, Indent indent) const;
149 
150  virtual void
151  PrintHeader(std::ostream & os, Indent indent) const;
152 
153  virtual void
154  PrintTrailer(std::ostream & os, Indent indent) const;
155 
160  virtual LightObject::Pointer
161  InternalClone() const;
162 
164  mutable std::atomic<int> m_ReferenceCount;
165 };
166 
173 ITKCommon_EXPORT std::ostream &
174  operator<<(std::ostream & os, const LightObject & o);
175 
176 } // end namespace itk
177 
178 #endif
itkTimeStamp.h
itk::operator<<
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:216
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itkMacro.h
itkIndent.h
GetNameOfClass
virtual const char * GetNameOfClass() const
itkWindows.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itkSmartPointer.h
itk::LightObject::Clone
Pointer Clone() const
Definition: itkLightObject.h:79
New
static Pointer New()
itk::LightObject::m_ReferenceCount
std::atomic< int > m_ReferenceCount
Definition: itkLightObject.h:164