From: Dejan L. <le...@us...> - 2004-06-06 20:54:16
|
Update of /cvsroot/rtk/rtk/rtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20076 Modified Files: Buffer.h Log Message: Added few constructors and methods. Previous Buffer.h version is completely removed. Index: Buffer.h =================================================================== RCS file: /cvsroot/rtk/rtk/rtk/Buffer.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Buffer.h 19 Apr 2004 22:53:44 -0000 1.3 --- Buffer.h 6 Jun 2004 20:54:07 -0000 1.4 *************** *** 32,36 **** ***** * Authors (chronological order): ! * Dejan Lekic, de...@nu... (dejan§rtk.cx) * Contributors (chronological order): * $fname $lname, $email --- 32,36 ---- ***** * Authors (chronological order): ! * Dejan Lekic, de...@nu... (dejanrtk.cx) * Contributors (chronological order): * $fname $lname, $email *************** *** 59,112 **** { public: ! ! // CONSTRUCTORS ! ! /** ! * Default constructor. ! * @param element_size uint Size of buffer's element (in bytes). ! * @param size uint Initial size of buffer. ! */ ! Buffer(uint element_size=sizeof(uchar), uint size=128); ! ! // DESTRUCTORS ! ! /** ! * Default destructor. ! */ ! ~Buffer(); ! ! // SET METHODS ! ! /** ! * Sets new size of buffer to 'size'. ! * @param size uint New size of buffer. ! */ ! void SetSize(uint size) { _buffer->SetCount(size); } ! ! // GET METHODS ! ! /** ! * Returns storage size of buffer. In short - the maximum number ! * of elements that could be stored in buffer without new ! * allocation(s). ! * @return uint Number of elements buffer can hold without new allocation(s). ! */ ! uint GetSize() const { return _buffer->GetCount(); } ! ! // OTHER METHODS ! ! /** ! * Reads one single element (object) from buffer. ! * @return void* Pointer to value. ! */ ! void* Read(); ! ! bool Write(void* data); ! ! protected: ! uint _size; /// Buffer size ! Array* _buffer; /// Buffer data ! uint _pos; /// Current position in buffer private: }; // Buffer }; // Rtk namespace --- 59,101 ---- { public: ! /** ! * Default Buffer constructor. ! */ ! Buffer() : _size(0), _data(0) {} ! ! /** ! * Another Buffer constructor. ! */ ! Buffer(const uchar* data, uint size) ! : _size(size), _data(new uchar[_size]) ! { memcpy(_data, data, _size); } ! ! /** ! * Buffer's copy constructor. ! */ ! Buffer(const Buffer& buf) : _size(buf._size), _data(new char[_size]) ! { memcpy(_data, buf._data, _size); } ! ! /** ! * Buffer's destructor ! */ ! ~Buffer() { delete[] _data; } ! ! void operator=(const Buffer& buf) ! { ! delete[] _data; ! _size = buf._size; ! _data = new char[_size]; ! memcpy(_data, buf._data, _size); ! } ! ! /** ! * Returns pointer to Buffer's data. ! */ ! const uchar* Data() const { return _data; } ! private: + uint _size; /// Number of elements in Buffer + uchar* _data; /// Data }; // Buffer }; // Rtk namespace |