ITK  6.0.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  itkVirtualGetNameOfClassMacro(LightObject);
94 
95 #ifdef _WIN32
96 
97  void *
98  operator new(size_t);
99 
100  void *
101  operator new[](size_t);
102 
103  void
104  operator delete(void *);
105 
106  void
107  operator delete[](void *, size_t);
108 
109 #endif
110 
112  void
113  Print(std::ostream & os, Indent indent = 0) const;
114 
117  static void
118  BreakOnError();
119 
121  virtual void
122  Register() const;
123 
125  virtual void
126  UnRegister() const noexcept;
127 
129  virtual int
130  GetReferenceCount() const
131  {
132  return m_ReferenceCount;
133  }
134 
137  virtual void
138  SetReferenceCount(int);
139 
140 protected:
141  LightObject();
142  virtual ~LightObject();
143 
148  virtual void
149  PrintSelf(std::ostream & os, Indent indent) const;
150 
151  virtual void
152  PrintHeader(std::ostream & os, Indent indent) const;
153 
154  virtual void
155  PrintTrailer(std::ostream & os, Indent indent) const;
156 
161  virtual LightObject::Pointer
162  InternalClone() const;
163 
165  mutable std::atomic<int> m_ReferenceCount{};
166 };
167 
174 ITKCommon_EXPORT std::ostream &
175  operator<<(std::ostream & os, const LightObject & o);
176 
177 } // end namespace itk
178 
179 #endif
itkTimeStamp.h
itk::operator<<
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)
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
itkWindows.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itkSmartPointer.h
itk::LightObject::Clone
Pointer Clone() const
Definition: itkLightObject.h:79
New
static Pointer New()