Main Page   Class Hierarchy   Data Structures   File List   Data Fields  

RefCountBuffer.h

00001 // Filename     : RefCountBuffer.h
00002 // Purpose      : A reference counting buffer. Use for fast and efficient way to create buffers
00003 //            and pass them between your functions.
00004 // Author       : Erad Fridman
00005 // Date         : 15/11/2002
00006 
00007 #ifndef __REFCOUNT_BUFFER_H__
00008 #define __REFCOUNT_BUFFER_H__
00009 
00010 #include "refcount.h"
00011 
00012 class RefCountBufferImp : public RefCountObj {
00013 public:
00014         friend class RefCountBuffer;
00015 
00016 private:
00017         RefCountBufferImp (unsigned int size, const char *buffer);
00018         ~RefCountBufferImp ();
00019 
00020 private:
00021         char *_buf;
00022         unsigned int _size;
00023 };
00024 
00025 //---------------------------------------------------------------------------------------
00026 class RefCountBuffer {
00027 public:
00028         // c'tors & d'tor
00029         RefCountBuffer (unsigned int size = 0, const char *buffer = NULL);
00030         virtual ~RefCountBuffer();
00031         RefCountBuffer (const RefCountBuffer &other);
00032 
00033         // operator = overload
00034         RefCountBuffer & operator = (const RefCountBuffer &other);
00035 
00036         // RefCountBuffer methods
00037         char *get_data ()
00038         {
00039                 return _imp -> _buf;
00040         }
00041 
00042         const char *get_data () const
00043         {
00044                 return _imp -> _buf;
00045         }
00046 
00047         unsigned int get_size () const
00048         {
00049                 return _imp -> _size;
00050         }
00051 
00052         RefCountBuffer clone() const
00053         {
00054                 return RefCountBuffer(_imp->_size, _imp->_buf);
00055         }
00056 
00057 private:
00058         RefCountPtr <RefCountBufferImp> _imp;
00059 };
00060 
00061 RefCountBuffer operator + (const RefCountBuffer &x, const RefCountBuffer &y);
00062 
00063 #endif // __REFCOUNT_BUFFER_H__

Generated on Sun Mar 2 01:48:11 2003 for Agent by doxygen1.3-rc3