ITK  5.2.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  * 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 #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 // To get LONG defined
32 # include "itkWindows.h"
33 #elif defined(__APPLE__)
34 // To get MAC_OS_X_VERSION_MIN_REQUIRED defined
35 # include <AvailabilityMacros.h>
36 #endif
37 
38 namespace itk
39 {
59 class ITKCommon_EXPORT LightObject
60 {
61 public:
62  ITK_DISALLOW_COPY_AND_MOVE(LightObject);
63 
65  using Self = LightObject;
68 
70  static Pointer
71  New();
72 
78  virtual Pointer
79  CreateAnother() const;
80 
82  Pointer
83  Clone() const
84  {
85  return this->InternalClone();
86  }
87 
91  virtual void
92  Delete();
93 
97  virtual const char *
98  GetNameOfClass() const;
99 
100 #ifdef _WIN32
101 
102  void * operator new(size_t);
103 
104  void * operator new[](size_t);
105 
106  void
107  operator delete(void *);
108 
109  void
110  operator delete[](void *, size_t);
111 
112 #endif
113 
115  void
116  Print(std::ostream & os, Indent indent = 0) const;
117 
120  static void
121  BreakOnError();
122 
124  virtual void
125  Register() const;
126 
128  virtual void
129  UnRegister() const noexcept;
130 
132  virtual int
133  GetReferenceCount() const
134  {
135  return m_ReferenceCount;
136  }
137 
140  virtual void
141  SetReferenceCount(int);
142 
143 protected:
144  LightObject();
145  virtual ~LightObject();
146 
151  virtual void
152  PrintSelf(std::ostream & os, Indent indent) const;
153 
154  virtual void
155  PrintHeader(std::ostream & os, Indent indent) const;
156 
157  virtual void
158  PrintTrailer(std::ostream & os, Indent indent) const;
159 
164  virtual LightObject::Pointer
165  InternalClone() const;
166 
168  mutable std::atomic<int> m_ReferenceCount;
169 };
170 
177 ITKCommon_EXPORT std::ostream &
178  operator<<(std::ostream & os, const LightObject & o);
179 
180 } // end namespace itk
181 
182 #endif
itkTimeStamp.h
itk::operator<<
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:218
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:59
itkMacro.h
itkIndent.h
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:83
itk::LightObject::m_ReferenceCount
std::atomic< int > m_ReferenceCount
Definition: itkLightObject.h:168