00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef __NEPOINTER_H
00028 #define __NEPOINTER_H
00029
00030
00037 #include "base.h"
00038
00039 #include <assert.h>
00040
00041 #ifdef WIN32
00042 # include <vector>
00043 #endif
00044
00045
00046 namespace NeoEngine
00047 {
00048
00049
00059 class NEOENGINE_API RefCounter
00060 {
00061 private:
00062
00064 int m_iRefCount;
00065
00066
00067 public:
00068
00072 inline RefCounter();
00073
00077 inline virtual ~RefCounter();
00078
00082 inline void IncRef();
00083
00087 inline void DecRef();
00088
00092 inline int GetRefCount() const;
00093 };
00094
00095
00106 template < class T > class Pointer
00107 {
00108 private:
00109
00111 T *m_pkObject;
00112
00113 public:
00114
00119 inline Pointer( T *pkObject = 0 );
00120
00125 inline Pointer( const Pointer< T > &rkPointer );
00126
00130 inline ~Pointer();
00131
00135 inline operator const bool () const;
00136
00140 inline operator T* ();
00141
00145 inline operator const T* () const;
00146
00150 inline T &operator * ();
00151
00155 inline const T &operator * () const;
00156
00160 inline T *operator -> ();
00161
00165 inline const T *operator -> () const;
00166
00170 inline bool operator !() const;
00171
00177 inline Pointer< T > &operator = ( const Pointer< T > &rkPointer );
00178
00184 inline Pointer< T > &operator = ( T *pkObject );
00185
00190 inline bool operator == ( const Pointer< T > &rkPointer ) const;
00191
00196 inline bool operator == ( const T *pkObject ) const;
00197
00202 inline bool operator != ( const Pointer< T > &rkPointer ) const;
00203
00208 inline bool operator != ( const T *pkObject ) const;
00209
00214 inline bool operator < ( const Pointer< T > &rkPointer ) const;
00215
00220 inline bool operator < ( const T *pkObject ) const;
00221 };
00222
00223
00224 #include "pointer_inl.h"
00225
00226
00227
00228
00229 #ifdef WIN32
00230 # ifdef _MSC_VER
00231 # pragma warning( disable : 4786 )
00232 # endif
00233 # if ( _MSC_VER >= 1300 )
00234 # define SmartPointer( classname ) \
00235 class classname; \
00236 typedef Pointer< classname > classname##Ptr; \
00237 EXPIMP_TEMPLATE template class NEOENGINE_API Pointer< classname >; \
00238 EXPIMP_TEMPLATE template class NEOENGINE_API std::allocator< Pointer< classname > >; \
00239 EXPIMP_TEMPLATE template class NEOENGINE_API std::vector< Pointer< classname > >
00240 # elif defined( _MSC_VER )
00241 # define SmartPointer( classname ) \
00242 class classname; \
00243 typedef Pointer< classname > classname##Ptr; \
00244 EXPIMP_TEMPLATE template class NEOENGINE_API Pointer< classname >; \
00245 EXPIMP_TEMPLATE template class NEOENGINE_API std::vector< Pointer< classname > >
00246 # else
00247 # define SmartPointer(classname) typedef Pointer< classname > classname##Ptr
00248 # endif
00249 #else
00250 # define SmartPointer(classname) typedef Pointer< classname > classname##Ptr
00251 #endif
00252
00253
00254 };
00255
00256
00257 #endif