Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

CTBsharedBuffer.hxx

Go to the documentation of this file.
00001 #ifndef _CTBsharedBuffer_HXX
00002 #define _CTBsharedBuffer_HXX 1
00003 
00008 /*----------------------------------------------------------------------------*/
00009 /* C Tool Box: Designed and implemented by:                                   */
00010 /*    Walter F.J. Mueller   Gesellschaft fuer Schwerionenforschung (GSI)      */
00011 /*                          Planckstrasse 1, D-64291 Darmstadt, Germany       */
00012 /*                  Email:  W.F.J.Mueller@gsi.de                              */
00013 /*                  WWW:    http://www-kp3.gsi.de/www/kp3/people/mueller.html */
00014 /*------------------------------------------+---------------------------------*/
00015 
00016 #include "CTBreferenceCounter.hxx"
00017 #include "CTBgrab.hxx"
00018 
00019 template <class T>
00020 class CTBsharedBuffer {
00021   public:
00022                     CTBsharedBuffer();
00023     explicit        CTBsharedBuffer(CTBint i_size);
00024                     CTBsharedBuffer(const CTBsharedBuffer<T>& rhs);
00025                     CTBsharedBuffer(CTBsharedBuffer<T>& rhs, bool b_grab);
00026 
00027                     ~CTBsharedBuffer();
00028 
00029     T*              Data() const;
00030     CTBint          Size() const;
00031 
00032     const T&        At(CTBint i_ind) const;
00033     T&              At(CTBint i_ind);
00034 
00035     void            Release();
00036     void            Unshare();
00037     void            Resize(CTBint i_size, bool b_keep=true);
00038 
00039     void            Grab(CTBsharedBuffer<T>& rhs);
00040     void            SharedCopy(const CTBsharedBuffer<T>& rhs);
00041     void            PrivateCopy(const CTBsharedBuffer<T>& rhs);
00042 
00043     bool            IsNull() const;
00044     bool            IsUnique() const;
00045     bool            IsShared() const;
00046 
00047     void            Dump(int i_indent=0, ostream& os=cout,
00048                          const char* p_text=0) const;
00049 
00050     CTBsharedBuffer<T>& operator=(
00051                       const CTBsharedBuffer<T>& rhs);    
00052 
00053     const T&        operator[](CTBint i_ind) const;
00054     T&              operator[](CTBint i_ind);
00055 
00056     bool            operator==(const CTBsharedBuffer<T>& rhs) const;
00057 
00058     bool            operator! () const;
00059 
00060                     operator bool() const;
00061 
00062   private: 
00063 
00064     void            CreateBuffer(CTBint i_size);
00065     void            CopyData(const T rhs[], CTBint i_size);
00066 
00067   private: 
00068 
00069     T*              mp_data;                
00070     CTBint          mi_size;                
00071     CTBreferenceCounter*  mp_refcount;      
00072 
00073 };
00074 
00075 template <class T>
00076 class CTBgrab<CTBsharedBuffer<T> > : public CTBgrabable<CTBsharedBuffer<T> > {};
00077 
00078 #include "CTBsharedBuffer.icc"
00079 
00080 #endif

Generated at Fri Oct 24 18:11:30 2003 for CTBbase by doxygen1.2.9-20010812 written by Dimitri van Heesch, © 1997-2001