Horus Doc || Corba Reference || Corba   Client Server   Stubs C++   Stubs Java   Servant Generator  

HxRefCountBase.h

Go to the documentation of this file.
00001 /*
00002  *  Copyright (c) 2000, University of Amsterdam, The Netherlands.
00003  *  All rights reserved.
00004  *
00005  *
00006  *  Author(s):
00007  *  Marc Navarro            (mnavarro@wins.uva.nl)
00008  */
00009 
00010 #ifndef HxRefCountBase_h
00011 #define HxRefCountBase_h
00012 
00013 
00014 class HxRefCountBase
00015 {
00016 public:
00017 
00018     virtual void            addRef(int num = 1);
00019     virtual void            removeRef(); // also with num?
00020     virtual void            destroy() = 0;
00021 
00022     int                     refCnt() const;
00023 protected:
00024                             HxRefCountBase();
00025     virtual                 ~HxRefCountBase();
00026 
00027 private:
00028     int                     _refCnt;
00029 };
00030 
00031 
00032 inline
00033 HxRefCountBase::HxRefCountBase() : _refCnt(0)
00034 {
00035 }
00036 
00037 inline
00038 HxRefCountBase::~HxRefCountBase()
00039 {
00040 }
00041 
00042 inline void
00043 HxRefCountBase::addRef(int num)
00044 { 
00045     _refCnt += num; 
00046 } 
00047 
00048 inline void
00049 HxRefCountBase::removeRef()
00050 { 
00051     std::cout << "removing ref from " << _refCnt << std::endl;
00052     if (--_refCnt <= 0) 
00053         destroy(); 
00054 }
00055 
00056 inline int
00057 HxRefCountBase::refCnt() const
00058 {
00059     return _refCnt;
00060 }
00061 
00062 #endif

Generated on Mon Jan 27 15:20:51 2003 for CorbaReference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001