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

RefCountPtrT.h

00001 #ifndef _LCORE_RefCountPtrT_H_  // -*-c++-*-
00002 
00003 #ifdef __GNUG__
00004 #  pragma interface
00005 #endif
00006 
00007 /*
00008  * Copyright (C) 1991-9 Eric M. Hopper <hopper@omnifarious.mn.org>
00009  * 
00010  *     This program is free software; you can redistribute it and/or modify it
00011  *     under the terms of the GNU Lesser General Public License as published
00012  *     by the Free Software Foundation; either version 2 of the License, or
00013  *     (at your option) any later version.
00014  * 
00015  *     This program is distributed in the hope that it will be useful, but
00016  *     WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  *     Lesser General Public License for more details.
00019  * 
00020  *     You should have received a copy of the GNU Lesser General Public
00021  *     License along with this program; if not, write to the Free Software
00022  *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00023  */
00024 
00025 /* $Header: /home/hopper/src/cvs/C++/LCore/LCore/RefCountPtrT.h,v 1.8 2002/05/09 21:55:21 hopper Exp $ */
00026 
00027 // For log see ../ChangeLog
00028 //
00029 // Revision 1.2  1997/05/12 14:36:03  hopper
00030 // Removed dangerous two dangerous operator =.
00031 //
00032 // Revision 1.1  1997/05/12 14:32:55  hopper
00033 // Added new RefCountPtr class, and RefCountPtrT class to aid in using
00034 // the ReferenceCounting mixin class.
00035 //
00036 
00037 #ifndef _LCORE_Protocol_H_
00038 #  include <LCore/Protocol.h>
00039 #endif
00040 #ifndef _EH_0_RefCounting_H_
00041 #  include <LCore/RefCounting.h>
00042 #endif
00043 #ifndef _LCORE_RefCountPtr_H_
00044 #  include <LCore/RefCountPtr.h>
00045 #endif
00046 
00047 #define _LCORE_RefCountPtrT_H_
00048 
00049 namespace strmod {
00050 namespace lcore {
00051 
00052 template <class T>
00053 class RefCountPtrT : public RefCountPtr {
00054  public:
00055    RefCountPtrT(const RefCountPtrT<T> &b) : RefCountPtr(b)                  { }
00056    inline RefCountPtrT(T *rfptr = 0);
00057 
00058    inline T &operator *() const;
00059    inline T *operator ->() const;
00060 
00061    inline T *GetPtr() const;
00062 
00063    inline const RefCountPtrT<T> &operator =(const RefCountPtrT<T> &b);
00064    inline const RefCountPtrT<T> &operator =(const RefCountPtr &b);
00065    inline const RefCountPtrT<T> &operator =(T *b);
00066 
00067  protected:
00068    inline virtual ReferenceCounting *i_CheckType(ReferenceCounting *p) const;
00069 };
00070 
00071 //-----------------------------inline functions--------------------------------
00072 
00073 template <class T>
00074 inline RefCountPtrT<T>::RefCountPtrT(T *rfptr) : RefCountPtr(rfptr)
00075 {
00076 }
00077 
00078 template <class T>
00079 inline T &RefCountPtrT<T>::operator *() const
00080 {
00081    return(*GetPtr());
00082 }
00083 
00084 template <class T>
00085 inline T *RefCountPtrT<T>::operator ->() const
00086 {
00087    return(GetPtr());
00088 }
00089 
00090 template <class T>
00091 inline T *RefCountPtrT<T>::GetPtr() const
00092 {
00093    return(static_cast<T *>(RefCountPtr::GetPtr()));
00094 }
00095 
00096 template <class T>
00097 inline const RefCountPtrT<T> &
00098 RefCountPtrT<T>::operator =(const RefCountPtrT<T> &b)
00099 {
00100    RefCountPtr::operator =(b);
00101    return(*this);
00102 }
00103 
00104 template <class T>
00105 inline const RefCountPtrT<T> &
00106 RefCountPtrT<T>::operator =(const RefCountPtr &b)
00107 {
00108    RefCountPtr::operator =(b);
00109    return(*this);
00110 }
00111 
00112 template <class T>
00113 inline const RefCountPtrT<T> &
00114 RefCountPtrT<T>::operator =(T *b)
00115 {
00116    RefCountPtr::operator =(b);
00117    return(*this);
00118 }
00119 
00120 template <class T>
00121 inline ReferenceCounting *
00122 RefCountPtrT<T>::i_CheckType(ReferenceCounting *p) const
00123 {
00124    return(p->AreYouA(T::identifier) ? p : 0);
00125 }
00126 
00127 } // namespace lcore
00128 } // namespace strmod
00129 
00130 #endif

Generated on Wed Jan 29 00:32:44 2003 for libNet by doxygen1.3-rc1