CBlobT< T > Class Template Reference

Blob - simple dynamic T array. More...

#include <blob.hpp>

Inheritance diagram for CBlobT< T >:
ByteBlob

Data Structures

struct  OnTransfer

Public Types

typedef ByteBlob base

Public Member Functions

FORCEINLINE CBlobT ()
 Default constructor - makes new Blob ready to accept any data.
FORCEINLINE CBlobT (const OnTransfer &ot)
 Take ownership constructor.
FORCEINLINE ~CBlobT ()
 Destructor - ensures that allocated memory (if any) is freed.
FORCEINLINE void CheckIdx (size_t index) const
 Check the validity of item index (only in debug mode).
FORCEINLINE T * Data ()
 Return pointer to the first data item - non-const version.
FORCEINLINE const T * Data () const
 Return pointer to the first data item - const version.
FORCEINLINE T * Data (size_t index)
 Return pointer to the index-th data item - non-const version.
FORCEINLINE const T * Data (size_t index) const
 Return pointer to the index-th data item - const version.
FORCEINLINE size_t Size () const
 Return number of items in the Blob.
FORCEINLINE size_t MaxSize () const
 Return total number of items that can fit in the Blob without buffer reallocation.
FORCEINLINE size_t GetReserve () const
 Return number of additional items that can fit in the Blob without buffer reallocation.
FORCEINLINE T * GrowSizeNC (size_t num_items)
 Grow number of data items in Blob by given number - doesn't construct items.
FORCEINLINE T * MakeFreeSpace (size_t num_items)
 Ensures that given number of items can be added to the end of Blob.
FORCEINLINE OnTransfer Transfer ()

Static Public Attributes

static const size_t type_size = sizeof(T)

Detailed Description

template<typename T>
class CBlobT< T >

Blob - simple dynamic T array.

T (template argument) is a placeholder for any type. T can be any integral type, pointer, or structure. Using Blob instead of just plain C array simplifies the resource management in several ways: 1. When adding new item(s) it automatically grows capacity if needed. 2. When variable of type Blob comes out of scope it automatically frees the data buffer. 3. Takes care about the actual data size (number of used items). 4. Dynamically constructs only used items (as opposite of static array which constructs all items)

Definition at line 304 of file blob.hpp.


Member Function Documentation

template<typename T>
FORCEINLINE T* CBlobT< T >::MakeFreeSpace ( size_t  num_items  )  [inline]

Ensures that given number of items can be added to the end of Blob.

Returns pointer to the first free (unused) item

Definition at line 394 of file blob.hpp.


The documentation for this class was generated from the following file:

Generated on Sun Jun 5 04:20:49 2011 for OpenTTD by  doxygen 1.6.1