Orfeo Toolbox  4.0
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 
157 
160 
161 private:
162  LightObject(const Self &); //purposely not implemented
163  void operator=(const Self &); //purposely not implemented
164 };
165 } // end namespace itk
166 
167 #endif

Generated at Sat Mar 8 2014 15:09:17 for Orfeo Toolbox with doxygen 1.8.3.1