ITK  4.6.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 "itkSimpleFastMutexLock.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  { return "LightObject"; }
85 
86 #ifdef _WIN32
87 
88  void * operator new(size_t);
89 
90  void * operator new[](size_t);
91 
92  void operator delete(void *);
93 
94  void operator delete[](void *, size_t);
95 
96 #endif
97 
99  void Print(std::ostream & os, Indent indent = 0) const;
100 
103  static void BreakOnError();
104 
106  virtual void Register() const;
107 
109  virtual void UnRegister() const;
110 
112  virtual int GetReferenceCount() const
113  { return static_cast< int >( m_ReferenceCount ); }
114 
117  virtual void SetReferenceCount(int);
118 
119 protected:
120  LightObject():m_ReferenceCount(1) {}
121  virtual ~LightObject();
122 
127  virtual void PrintSelf(std::ostream & os, Indent indent) const;
128 
129  virtual void PrintHeader(std::ostream & os, Indent indent) const;
130 
131  virtual void PrintTrailer(std::ostream & os, Indent indent) const;
132 
137  virtual LightObject::Pointer InternalClone() const;
138 
141 #if ( defined( WIN32 ) || defined( _WIN32 ) )
142  typedef LONG InternalReferenceCountType;
143 #elif defined( __APPLE__ ) && ( MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 )
144  #if defined ( __LP64__ ) && __LP64__
145  typedef volatile int64_t InternalReferenceCountType;
146  #else
147  typedef volatile int32_t InternalReferenceCountType;
148  #endif
149 #elif defined( __GLIBCPP__ ) || defined( __GLIBCXX__ )
150  typedef _Atomic_word InternalReferenceCountType;
151 #else
153 #endif
154 
155 
158 
161 
162 private:
163  LightObject(const Self &); //purposely not implemented
164  void operator=(const Self &); //purposely not implemented
165 };
166 
173 std::ostream &
174 operator<<(std::ostream & os, const LightObject & o);
175 
176 } // end namespace itk
177 
178 #endif
Critical section locking class that can be allocated on the stack.
Light weight base class for most itk classes.
virtual const char * GetNameOfClass() const
SmartPointer< const Self > ConstPointer
LightObject Self
typedef::itksysFundamentalType_Int64 int64_t
Definition: itkIntTypes.h:88
SmartPointer< Self > Pointer
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:184
InternalReferenceCountType m_ReferenceCount
SimpleFastMutexLock m_ReferenceCountLock
virtual int GetReferenceCount() const
typedef::itksysFundamentalType_Int32 int32_t
Definition: itkIntTypes.h:86
Control indentation during Print() invocation.
Definition: itkIndent.h:49