ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkLightObject.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 "itkAtomicInt.h"
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 {
55 class ITKCommon_EXPORT LightObject
56 {
57 public:
59  typedef LightObject Self;
62 
64  static Pointer New();
65 
71  virtual Pointer CreateAnother() const;
72 
73  itkCloneMacro(Self);
74 
78  virtual void Delete();
79 
83  virtual const char * GetNameOfClass() const;
84 
85 #ifdef _WIN32
86 
87  void * operator new(size_t);
88 
89  void * operator new[](size_t);
90 
91  void operator delete(void *);
92 
93  void operator delete[](void *, size_t);
94 
95 #endif
96 
98  void Print(std::ostream & os, Indent indent = 0) const;
99 
102  static void BreakOnError();
103 
105  virtual void Register() const;
106 
108  virtual void UnRegister() const ITK_NOEXCEPT;
109 
111  virtual int GetReferenceCount() const
112  { return m_ReferenceCount; }
113 
116  virtual void SetReferenceCount(int);
117 
118 protected:
119  LightObject();
120  virtual ~LightObject();
121 
126  virtual void PrintSelf(std::ostream & os, Indent indent) const;
127 
128  virtual void PrintHeader(std::ostream & os, Indent indent) const;
129 
130  virtual void PrintTrailer(std::ostream & os, Indent indent) const;
131 
136  virtual LightObject::Pointer InternalClone() const;
137 
140 
141 
142 private:
143  LightObject(const Self &) ITK_DELETE_FUNCTION;
144  void operator=(const Self &) ITK_DELETE_FUNCTION;
145 };
146 
153 std::ostream &
154 operator<<(std::ostream & os, const LightObject & o);
155 
156 } // end namespace itk
157 
158 #endif
Light weight base class for most itk classes.
SmartPointer< const Self > ConstPointer
LightObject Self
SmartPointer< Self > Pointer
AtomicInt< int > m_ReferenceCount
Control indentation during Print() invocation.
Definition: itkIndent.h:49