ITK  5.1.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_ASSIGN(LightObject);
63 
65  using Self = LightObject;
68 
70  static Pointer
71  New();
72 
78  virtual Pointer
79  CreateAnother() const;
80 
81  itkCloneMacro(Self);
82 
86  virtual void
87  Delete();
88 
92  virtual const char *
93  GetNameOfClass() const;
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<<
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:213
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: itkArray.h:26
itkSmartPointer.h
itk::LightObject::m_ReferenceCount
std::atomic< int > m_ReferenceCount
Definition: itkLightObject.h:163