D:/WorkDir/SugoiProjects/SugoiTools/include/SugoiTools/smart_ptr.h

00001 //==========================================================
00002 // SmartPtr.h
00003 //
00004 // Définition de la classe CSmartPtr
00005 //
00006 //==========================================================
00007 
00008 #ifndef SMARTPTR_H
00009 #define SMARTPTR_H
00010 
00011 
00012 //==========================================================
00013 // En-têtes
00014 //==========================================================
00015 #include "SugoiTools\config.h"
00016  
00017 
00018 
00019 #if _SG_TLS_SMARTPTR
00020 
00021 #include <cstdlib>
00022 #include "SugoiTools\exceptions.h"
00023 //#include "SugoiTools\debug_new.h"
00024 
00025 namespace SGE{
00026 
00027     //==========================================================
00028     // Pointeurs intelligent utilisant le comptage de références
00029     //==========================================================
00030     template <class T>
00031     class CSmartPtr
00032     {
00033     public :
00034 
00035         //----------------------------------------------------------
00036         // Constructeur par défaut
00037         //----------------------------------------------------------
00038         CSmartPtr();
00039 
00040         //----------------------------------------------------------
00041         // Constructeur par copie
00042         //----------------------------------------------------------
00043         CSmartPtr(const CSmartPtr& Copy);
00044 
00045         //----------------------------------------------------------
00046         // Constructeur à partir d'un pointeur
00047         //----------------------------------------------------------
00048         CSmartPtr(T* Pointer);
00049 
00050         //----------------------------------------------------------
00051         // Destructeur
00052         //----------------------------------------------------------
00053         ~CSmartPtr();
00054 
00055         //----------------------------------------------------------
00056         // Opérateurs de déréférencement
00057         //----------------------------------------------------------
00058         T& operator * ();
00059         T* operator ->();
00060 
00061         //----------------------------------------------------------
00062         // Opérateur d'affectation
00063         //----------------------------------------------------------
00064         const CSmartPtr& operator =(CSmartPtr pPointer);
00065 
00066         //----------------------------------------------------------
00067         // Opérateurs de comparaison
00068         //----------------------------------------------------------
00069         //bool operator ==(const CSmartPtr& pPointer) const;
00070         //bool operator !=(const CSmartPtr& pPointer) const;
00071 
00072         //----------------------------------------------------------
00073         // Opérateur de cast en T*
00074         //----------------------------------------------------------
00075         operator T*() const;
00076 
00077                     bool IsValide();
00078 
00079     private :
00080 
00081         //----------------------------------------------------------
00082         // Echange deux CSmartPtr
00083         //----------------------------------------------------------
00084         void Swap(CSmartPtr& Ptr);
00085 
00086         //----------------------------------------------------------
00087         // Données membres
00088         //----------------------------------------------------------
00089         T*   m_Data;
00090         int* m_Counter;
00091                     bool OnWrite;
00092     };
00093 
00094 //    #include "SugoiTools\SmartPtr.inl"
00095 
00096   //  #include "SugoiTools\debug_new_off.h"
00097 };//namespace SGE
00098 #else
00099 /*namespace SGE{
00100 
00101           template <class T>
00102           class CSmartPtr : public T
00103     {
00104     public :
00105 
00106     
00107     };
00108 
00109 };//namespace SGE
00110 */
00111 #endif //_SG_TLS_SMARTPTR
00112 #endif // SMARTPTR_H

Generated on Mon Mar 19 23:15:11 2007 for SugoiTools by  doxygen 1.4.6-NO