Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkLightObject.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkLightObject.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-05-20 22:03:31 $
00007   Version:   $Revision: 1.41 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
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 #if defined(_WIN32)
00030   // To get LONG defined
00031   #include "itkWindows.h"
00032 #elif defined(__APPLE__)
00033   // To get MAC_OS_X_VERSION_MIN_REQUIRED defined
00034   #include <AvailabilityMacros.h>
00035 #endif
00036 
00037 namespace itk
00038 {
00039   
00054 class ITKCommon_EXPORT LightObject 
00055 {
00056 public:
00058   typedef LightObject         Self;
00059   typedef SmartPointer<Self>  Pointer;
00060   typedef SmartPointer<const Self>  ConstPointer;
00061 
00063   static Pointer New();
00064 
00070   virtual Pointer CreateAnother() const;
00071 
00075   virtual void Delete();
00076 
00080   virtual const char *GetNameOfClass() const 
00081     {return "LightObject";}
00082 
00083 #ifdef _WIN32
00084 
00085   void* operator new(size_t);
00086   void* operator new[](size_t);
00087   void operator delete(void*);
00088   void operator delete[](void*, size_t);
00089 #endif 
00090 
00091 
00093   void Print(std::ostream& os, Indent indent=0) const;
00094 
00097   static void BreakOnError();
00098 
00100   virtual void Register() const;
00101 
00103   virtual void UnRegister() const;
00104 
00106   virtual int GetReferenceCount() const 
00107     {return static_cast<int>(m_ReferenceCount);}
00108 
00111   virtual void SetReferenceCount(int);
00112 
00113 protected:
00114   LightObject():m_ReferenceCount(1) {}
00115   virtual ~LightObject(); 
00116 
00121   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00122   virtual void PrintHeader(std::ostream& os, Indent indent) const;
00123   virtual void PrintTrailer(std::ostream& os, Indent indent) const;
00125 
00128 #if (defined(WIN32) || defined(_WIN32))
00129   typedef LONG InternalReferenceCountType;
00130 #elif defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1050)
00131  #if defined (__LP64__) && __LP64__
00132   typedef volatile int64_t InternalReferenceCountType;
00133  #else
00134   typedef volatile int32_t InternalReferenceCountType;
00135  #endif
00136 #elif defined(__GLIBCPP__) || defined(__GLIBCXX__)
00137   typedef _Atomic_word InternalReferenceCountType;
00138 #else
00139   typedef int InternalReferenceCountType;
00140 #endif
00141 
00142 
00144   mutable InternalReferenceCountType m_ReferenceCount;
00145 
00147   mutable SimpleFastMutexLock m_ReferenceCountLock;
00148 
00149 private:
00150   LightObject(const Self&); //purposely not implemented
00151   void operator=(const Self&); //purposely not implemented
00152   
00153   
00154 };
00155 
00156 } // end namespace itk
00157   
00158 #endif
00159 

Generated at Wed Nov 5 22:39:50 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000