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

gptr.h

Go to the documentation of this file.
00001 #ifndef _GPTR_H_
00002 #define _GPTR_H_
00003 #include <coconut_config.h>
00004 
00005 template <class _Tp>
00006 class gptr
00007 {
00008 private:
00009   typedef _Tp& reference;
00010   typedef _Tp* pointer;
00011   typedef const _Tp& const_reference;
00012   typedef const _Tp* const_pointer;
00013 public:
00014   virtual ~gptr() {}
00015 
00016   virtual reference operator*() PURE_VIRTUAL
00017   virtual const_reference operator*() const PURE_VIRTUAL
00018 
00019   virtual pointer operator->() PURE_VIRTUAL
00020   virtual const_pointer operator->() const PURE_VIRTUAL
00021 
00022   virtual pointer get_local_copy() PURE_VIRTUAL
00023   virtual const_pointer get_local_copy() const PURE_VIRTUAL
00024 };
00025 
00026 template <class _Tp>
00027 class ptr : public gptr<_Tp>
00028 {
00029 private:
00030   typedef ptr<_Tp> _Self;
00031 
00032   typedef _Tp& reference;
00033   typedef _Tp* pointer;
00034   typedef const _Tp& const_reference;
00035   typedef const _Tp* const_pointer;
00036   
00037   _Tp* _p;
00038 public:
00039   ptr(_Tp& __p) : _p(&__p) {}
00040   ptr(_Tp* __p) : _p(__p) {}
00041   ptr(const _Self& __p) : _p(__p._p) {}
00042 
00043   ~ptr() {}
00044 
00045   reference operator*() { return *_p; }
00046   const_reference operator*() const { return *_p; }
00047 
00048   pointer operator->() { return _p; }
00049   const_pointer operator->() const { return _p; }
00050 
00051   pointer get_local_copy() { return _p; }
00052   const_pointer get_local_copy() const { return _p; }
00053 
00054   _Self& operator=(const _Self& __p) { _p = __p._p; return *this; }
00055   _Self& operator=(_Tp& __p) { _p = &__p; return *this; }
00056 };
00057 
00058 #endif /* _GPTR_H_ */

Generated on Tue Nov 4 01:57:57 2003 for COCONUT API by doxygen1.2.18