00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkLightObject_h
00018 #define __itkLightObject_h
00019
00020 #include "itkSmartPointer.h"
00021 #include "itkTimeStamp.h"
00022 #include "itkIndent.h"
00023 #include "itkSimpleFastMutexLock.h"
00024 #include "itkMacro.h"
00025
00026 #include <iostream>
00027 #include <typeinfo>
00028
00029 namespace itk
00030 {
00031
00046 class ITKCommon_EXPORT LightObject
00047 {
00048 public:
00050 typedef LightObject Self;
00051 typedef SmartPointer<Self> Pointer;
00052 typedef SmartPointer<const Self> ConstPointer;
00053
00055 static Pointer New();
00056
00062 virtual Pointer CreateAnother() const;
00063
00067 virtual void Delete();
00068
00072 virtual const char *GetNameOfClass() const
00073 {return "LightObject";}
00074
00075 #ifdef _WIN32
00076
00077 void* operator new(size_t);
00078 void* operator new[](size_t);
00079 void operator delete(void*);
00080 void operator delete[](void*, size_t);
00081 #endif
00082
00083
00085 void Print(std::ostream& os, Indent indent=0) const;
00086
00089 static void BreakOnError();
00090
00092 virtual void Register() const;
00093
00095 virtual void UnRegister() const;
00096
00098 virtual int GetReferenceCount() const
00099 {return m_ReferenceCount;}
00100
00103 virtual void SetReferenceCount(int);
00104
00105 protected:
00106 LightObject():m_ReferenceCount(1) {}
00107 virtual ~LightObject();
00108
00113 virtual void PrintSelf(std::ostream& os, Indent indent) const;
00114 virtual void PrintHeader(std::ostream& os, Indent indent) const;
00115 virtual void PrintTrailer(std::ostream& os, Indent indent) const;
00117
00119 mutable volatile int m_ReferenceCount;
00120
00122 mutable SimpleFastMutexLock m_ReferenceCountLock;
00123
00124 private:
00125 LightObject(const Self&);
00126 void operator=(const Self&);
00127
00128
00129 };
00130
00131 }
00132
00133 #endif
00134