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 * operator new(size_t);
98 
99  void * operator new[](size_t);
100 
101  void
102  operator delete(void *);
103 
104  void
105  operator delete[](void *, size_t);
106 
107 #endif
108 
110  void
111  Print(std::ostream & os, Indent indent = 0) const;
112 
115  static void
116  BreakOnError();
117 
119  virtual void
120  Register() const;
121 
123  virtual void
124  UnRegister() const noexcept;
125 
127  virtual int
128  GetReferenceCount() const
129  {
130  return m_ReferenceCount;
131  }
132 
135  virtual void
136  SetReferenceCount(int);
137 
138 protected:
139  LightObject();
140  virtual ~LightObject();
141 
146  virtual void
147  PrintSelf(std::ostream & os, Indent indent) const;
148 
149  virtual void
150  PrintHeader(std::ostream & os, Indent indent) const;
151 
152  virtual void
153  PrintTrailer(std::ostream & os, Indent indent) const;
154 
159  virtual LightObject::Pointer
160  InternalClone() const;
161 
163  mutable std::atomic<int> m_ReferenceCount{};
164 };
165 
172 ITKCommon_EXPORT std::ostream &
173  operator<<(std::ostream & os, const LightObject & o);
174 
175 } // end namespace itk
176 
177 #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()