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 #if defined(_MSC_VER)
00021 #pragma warning ( disable : 4786 )
00022 #endif
00023
00024 #include <iostream>
00025 #include <typeinfo>
00026
00027 #include "itkSmartPointer.h"
00028 #include "itkTimeStamp.h"
00029 #include "itkIndent.h"
00030 #include "itkSimpleFastMutexLock.h"
00031
00032 #include "itkMacro.h"
00033
00034 namespace itk
00035 {
00036
00051 class ITKCommon_EXPORT LightObject
00052 {
00053 public:
00055 typedef LightObject Self;
00056 typedef SmartPointer<Self> Pointer;
00057 typedef SmartPointer<const Self> ConstPointer;
00058
00060 static Pointer New();
00061
00067 virtual Pointer CreateAnother() const;
00068
00072 virtual void Delete();
00073
00077 virtual const char *GetNameOfClass() const
00078 {return "LightObject";}
00079
00080 #ifdef _WIN32
00081
00082 void* operator new(size_t);
00083 void* operator new[](size_t);
00084 void operator delete(void*);
00085 void operator delete[](void*, size_t);
00086 #endif
00087
00089 void Print(std::ostream& os, Indent indent=0) const;
00090
00093 static void BreakOnError();
00094
00096 virtual void Register() const;
00097
00099 virtual void UnRegister() const;
00100
00102 virtual int GetReferenceCount() const
00103 {return m_ReferenceCount;}
00104
00107 virtual void SetReferenceCount(int);
00108
00109 protected:
00110 LightObject():m_ReferenceCount(1) {}
00111 virtual ~LightObject();
00112
00117 virtual void PrintSelf(std::ostream& os, Indent indent) const;
00118 virtual void PrintHeader(std::ostream& os, Indent indent) const;
00119 virtual void PrintTrailer(std::ostream& os, Indent indent) const;
00120
00122 mutable int m_ReferenceCount;
00123
00125 mutable SimpleFastMutexLock m_ReferenceCountLock;
00126
00127 private:
00128 LightObject(const Self&);
00129 void operator=(const Self&);
00130
00131
00132 };
00133
00134 }
00135
00136 #endif