#include <CTBrawBuffer.hxx>
Inheritance diagram for CTBrawBuffer:
Public Methods | |
CTBrawBuffer () | |
CTBrawBuffer (CTBint i_capacity) | |
CTBrawBuffer (CTBrawBuffer< T > &rhs, bool b_grab) | |
~CTBrawBuffer () | |
void | Construct (CTBint i_ind) |
void | Construct (T *p_ele) |
void | ConstructRange (CTBint i_beg, CTBint i_size) |
void | Construct (CTBint i_ind, const T &value) |
void | Construct (T *p_ele, const T &value) |
void | ConstructRange (CTBint i_beg, CTBint i_size, const T &value) |
void | ConstructRange (CTBint i_beg, CTBint i_size, const T rhs[]) |
void | Destruct (CTBint i_ind) |
void | Destruct (T *p_ele) |
void | DestructRange (CTBint i_beg, CTBint i_size) |
void | GrabConstruct (CTBint i_ind, T &value) |
void | GrabConstructRange (CTBint i_beg, CTBint i_size, T rhs[]) |
void | GrabDestruct (CTBint i_ind, T &obj) |
CTBint | Capacity () const |
void | Resize (CTBint i_capacity) |
void | Grab (CTBrawBuffer< T > &rhs) |
bool | Empty () const |
void | ShiftRight (CTBint i_beg, CTBint i_end) |
void | ShiftLeft (CTBint i_beg, CTBint i_end) |
void | Copy (CTBint i_beg, CTBint i_size, const T &rhs) |
void | Copy (CTBint i_beg, CTBint i_size, const T rhs[]) |
void | Dump (int i_indent=0, ostream &os=cout, const char *p_text=0) const |
T * | operator+ (CTBint i_ind) |
const T * | operator+ (CTBint i_ind) const |
T & | operator[] (CTBint i_ind) |
const T & | operator[] (CTBint i_ind) const |
bool | operator! () const |
operator T * () | |
operator const T * () const | |
Private Methods | |
void | DeleteBuffer () |
void | CreateBuffer (CTBint i_capacity) |
CTBrawBuffer (const CTBrawBuffer< T > &rhs) | |
CTBrawBuffer< T > & | operator= (const CTBrawBuffer< T > &rhs) |
Private Attributes | |
T * | mp_data |
CTBint | mi_capacity |
CTBrawBuffer
manages a buffer of raw memory and provides member functions for constructing and destructing objects in this raw memory area. This class is mainly used in the implementation of containers, like for example CTBvector
.
Note, that CTBrawBuffer
keeps only track of the amount of allocated raw memory, but does not track in which areas objects have been actually constructed. Therefore, it is the responsibility of the caller to destruct all constructed objects before a CTBrawBuffer
is destroyed.
Note, that CTBrawBuffer
objects are neither copyable and nor assignable ! This is because a CTBrawBuffer
object doesn't know which buffer elements have been constructed into an object and which ones are still raw memory. If a class has a member variable of type CTBrawBuffer
it has to explicitely implement a copy contructor and assignment operator which copies the constructed buffer elements, for example using the Copy()
function.
A copy constructor and an assigment operator is defined as private member function, but not implemented to prevent usage of the compiler generated functions.
Definition at line 19 of file CTBrawBuffer.hxx.
|
Default constructor.
Constructs an empty Definition at line 61 of file CTBrawBuffer.icc. |
|
Construct with given capacity.
Constructs an Definition at line 74 of file CTBrawBuffer.icc. |
|
Definition at line 85 of file CTBrawBuffer.icc. |
|
Destructor.
Will release the raw memory previously allocated by this object. Note, that the objects constructed within the raw memory must have been destructed before the destructor of the Definition at line 102 of file CTBrawBuffer.icc. |
|
|
|
Default construct element.
The buffer element with index i_ind is constructed into an object of type Definition at line 115 of file CTBrawBuffer.icc. Referenced by CTBvector::Insert(), CTBvector::InsertTail(), CTBvector::operator=(), and CTBmatrix::operator=().
|
|
Default construct element.
The buffer element pointed to by p_ele is constructed into an object of type Definition at line 130 of file CTBrawBuffer.icc. |
|
Default construct element range.
The i_size buffer elements starting at index i_beg are constructed into objects of type Definition at line 145 of file CTBrawBuffer.icc. Referenced by CTBmatrix::CTBmatrix(), CTBvector::CTBvector(), CTBvector::Resize(), CTBmatrix::Resize(), CTBvector::operator=(), and CTBmatrix::operator=().
|
|
Copy construct element.
The buffer element with index i_ind is constructed into an object of type Definition at line 162 of file CTBrawBuffer.icc. |
|
Copy construct element.
The buffer element pointed to by p_ele is constructed into an object of type Definition at line 177 of file CTBrawBuffer.icc. |
|
Construct element range from scalar.
i_size buffer elements starting at index i_beg are constructed into objects of type Definition at line 192 of file CTBrawBuffer.icc. |
|
Construct element range from array.
i_size buffer elements starting at index i_beg are constructed into objects of type Definition at line 211 of file CTBrawBuffer.icc. |
|
The buffer element with index i_ind is destructed.
Definition at line 225 of file CTBrawBuffer.icc. Referenced by CTBvector::ChangeCapacity(), CTBmatrix::ChangeCapacity(), and CTBvector::Delete().
|
|
The buffer element pointed to by p_ele is destructed.
Definition at line 235 of file CTBrawBuffer.icc. |
|
The i_size buffer elements starting at index i_beg are destrucuted.
Definition at line 246 of file CTBrawBuffer.icc. Referenced by CTBvector::Grab(), CTBmatrix::Grab(), CTBvector::Resize(), CTBmatrix::Resize(), CTBvector::operator=(), CTBmatrix::operator=(), CTBmatrix::~CTBmatrix(), and CTBvector::~CTBvector().
|
|
'Grab or copy' construct element with index i_ind from value.
Definition at line 259 of file CTBrawBuffer.icc. Referenced by CTBvector::ChangeCapacity(), and CTBmatrix::ChangeCapacity().
|
|
'Garb or copy' construct element range from array.
i_size buffer elements starting at index i_beg are constructed into objects of type Definition at line 277 of file CTBrawBuffer.icc. Referenced by CTBmatrix::Resize().
|
|
'Grab or copy' to obj the element with index i_ind, than destroy it.
Definition at line 292 of file CTBrawBuffer.icc. Referenced by CTBvector::RemoveTail().
|
|
Returns the capacity.
The capacity is the size of the allocated raw memory buffer in units of objects of type Definition at line 310 of file CTBrawBuffer.icc. Referenced by CTBvector::Capacity(), CTBmatrix::Capacity(), CTBvector::Grab(), CTBmatrix::Grab(), CTBmatrix::~CTBmatrix(), and CTBvector::~CTBvector().
|
|
Change capacity of buffer.
This function simply releases the old buffer and allocates a new one with a capacity of i_capacity. Therefore, all constructed objects must have been destructed before Definition at line 324 of file CTBrawBuffer.icc. Referenced by CTBvector::ChangeCapacity(), CTBmatrix::ChangeCapacity(), CTBvector::Grab(), CTBmatrix::Grab(), and CTBmatrix::Resize().
|
|
Grab resources.
The resources allocated for rhs will be transfered to the calling object. Note, that the object must be in Empty() state and that rhs must be a different object. In most other classes the grab method is protected against these cases, but in Definition at line 343 of file CTBrawBuffer.icc. Referenced by CTBvector::Grab(), CTBmatrix::Grab(), and CTBmatrix::Resize().
|
|
Returns true if no buffer allocated.
A Definition at line 362 of file CTBrawBuffer.icc. |
|
Shift range one position right.
The buffer elements in the range
The function uses the assignment operator for type
The function is a noop if Definition at line 384 of file CTBrawBuffer.icc. Referenced by CTBvector::Insert().
|
|
Shift range one position left.
The buffer elements in the range
The function uses the assignment operator for type
The function is a noop if Definition at line 416 of file CTBrawBuffer.icc. Referenced by CTBvector::Delete().
|
|
Copy scalar into rawbuffer.
The value of rhs is copied into i_size buffer elements starting at index i_beg using the assigment operator for type Definition at line 440 of file CTBrawBuffer.icc. Referenced by CTBvector::operator=(), and CTBmatrix::operator=().
|
|
Copy array into rawbuffer.
The first i_size elements of array rhs are i_size buffer elements starting at index i_beg using the assigment operator for type Definition at line 458 of file CTBrawBuffer.icc. |
|
Dump CTBrawBuffer object.
Definition at line 474 of file CTBrawBuffer.icc. Referenced by CTBvector::Dump(), and CTBmatrix::Dump().
|
|
Calculate pointer to the i_ind 'th buffer element. This operator allows to use a CTBrawBuffer object very much like a C array in index and pointer arithmetic. Expressions like CTBrawBuffer<int> buf; ... int* p1 = buf+3; int* p2 = &buf[3];
Note, that there is no Definition at line 520 of file CTBrawBuffer.icc. |
|
Calculate const pointer to the i_ind 'th buffer element.
Definition at line 529 of file CTBrawBuffer.icc. |
|
Access buffer element. A reference to the buffer element with index i_ind is returned. An access to this object is only defined if the element has been constructed before. Definition at line 497 of file CTBrawBuffer.icc. |
|
Constant access buffer element. A reference to the buffer element with index i_ind is returned. An access to this object is only defined if the element has been constructed before. Definition at line 542 of file CTBrawBuffer.icc. |
|
Returns
Definition at line 551 of file CTBrawBuffer.icc. |
|
Convert to pointer to data. Returns a pointer to the allocated buffer or 0 if the capacity is 0. Note, that the following tests are all equivalent: CTBrawBuffer<...> buf; if (buf) if (buf.Capacity() > 0) if (!buf.Empty()) if ((T*) buf) Definition at line 573 of file CTBrawBuffer.icc. |
|
Constant convert to pointer to data. Returns a pointer to the allocated buffer or 0 if the capacity is 0. Definition at line 585 of file CTBrawBuffer.icc. |
|
Release buffer memory.
Definition at line 594 of file CTBrawBuffer.icc. Referenced by Resize(), and ~CTBrawBuffer().
|
|
Create new buffer with capacity i_capacity.
Definition at line 608 of file CTBrawBuffer.icc. Referenced by CTBrawBuffer(), and Resize().
|
|
|
|
buffer area.
Definition at line 89 of file CTBrawBuffer.hxx. |
|
capacity of buffer.
Definition at line 90 of file CTBrawBuffer.hxx. |