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

EventPtrT.h

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

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