Description | Pool of data blocks |
Header file | LDataStore.h |
Author | Irene Finocchi |
Created | Dec 19, 2001 |
Last updated | Nov 28, 2002 |
The component LDataStore provides support for maintaining a pool of
data blocks, possibly of different sizes. Blocks are represented contiguously
in memory in a data segment containing the whole collection of blocks. Each
block has a logical index in the data segment in the range 0 to the
number of blocks -1 ([0,GetBlocksCount()-1]). Since the blocks
may have different sizes, a data map segment is also maintained to contain the
offset of each block in the data segment. Member functions allow it to add new
data blocks, to retrieve the block offset from the block index, to search for
a block index from the block data.
It is also possible to use LDataStore to maintain a data segment
in which identical blocks (as sequence of bytes) are represented only once.
To do so, new blocks must be added using the member function AddUniqueBlock
instead of AddBlock. A typical application is maintaining a pool of
strings of arbitrary lengths, where no two strings in the pool are allowed to
be equal.
Constants |
|
LDataStore_ID |
Types |
|
LDataStore LDataStore_TIdx |
Functions |
|
LDataStore* LDataStore_New (); LDataStore* LDataStore_NewFromData (LXPBlock* thruBlock); void LDataStore_Delete (LDataStore** ThisA); LDataStore_TIdx LDataStore_AddBlock (LDataStore* This, const void* inItem, ui4 inSize); LDataStore_TIdx LDataStore_AddXPBlock (LDataStore* This, const LXPBlock* inItem); LDataStore_TIdx LDataStore_AddUniqueBlock (LDataStore* This, const void* inItem, ui4 inSize); Bool LDataStore_GetBlockIndex (LDataStore* This, const void* inItem, ui4 inSize, LDataStore_TIdx* outIndex); ui4 LDataStore_GetOffsetByIndex (LDataStore* This, LDataStore_TIdx inIndex); ui4 LDataStore_GetSizeByIndex (LDataStore* This, LDataStore_TIdx inIndex); void LDataStore_FetchBlockByIndex(LDataStore* This, LDataStore_TIdx inIndex, void* outItem); void* LDataStore_GetDataByIndex (LDataStore* This, LDataStore_TIdx inIndex); LXPBlock* LDataStore_GetXPBlockByIndex(LDataStore* This, LDataStore_TIdx inIndex); void* LDataStore_GetData (LDataStore* This); ui4 LDataStore_GetSize (LDataStore* This); void* LDataStore_GetMap (LDataStore* This); ui4 LDataStore_GetMapSize (LDataStore* This); ui4 LDataStore_GetBlocksCount (LDataStore* This); LXPBlock* LDataStore_GetXPBlock (LDataStore* This); |
Function | Arguments | Description | Returns | Throws |
New | - | Create object containing an empty data store. Caller is responsible of dellocating the created object using LDataStore_Delete. |
LDataStore* |
- |
NewFromData | LXPBlock* thruBlock | Read data from thruBlock and create an LDataStore object. Caller is responsible of dellocating the created object using LDataStore_Delete. |
LDataStore* |
- |
Delete | LDataStore** ThisA | Release object *ThisA. *ThisA is set to NULL. | void | - |
AddBlock | LDataStore* This | Add block inItem of size inSize (in bytes) to the data pool. |
LDataStore_TIdx |
- |
const void* inItem | ||||
ui4 inSize | ||||
AddXPBlock | LDataStore* This | Add an XP block to the data pool. |
LDataStore_TIdx |
- |
const LXPBlock* inItem | ||||
AddUniqueBlock | LDataStore* This | Add a block to the data pool if it does not already exist. |
LDataStore_TIdx |
- |
const void* inItem | ||||
ui4 inSize | ||||
GetBlockIndex | LDataStore* This | Scan blocks in the data segment and check if block inItem of size inSize exists. If this is the case, set outIndex to contain its index in the data segment. | Bool TRUE if the item has been found, FALSE otherwise. |
- |
const void* inItem | ||||
ui4 inSize | ||||
LDataStore_TIdx* outIndex | ||||
GetOffsetByIndex
|
LDataStore* This | - | ui4 offset in the data segment of the block whose index is inIndex. |
- |
LDataStore_TIdx inIndex | ||||
GetSizeByIndex | LDataStore* This | - | ui4 size of the block whose index is inIndex. |
- |
LDataStore_TIdx inIndex | ||||
FetchBlockByIndex | LDataStore* This | Copy to buffer outBlock block with index inIndex. Buffer outBlock must be allocated by the caller and must be large enough to contain LDataStore_GetSizeByIndex(This,inIndex) bytes. |
- |
- |
LDataStore_TIdx inIndex | ||||
void* outBlock | ||||
GetDataByIndex | LDataStore* This | Return address of block with index inIndex. |
void* |
- |
LDataStore_TIdx inIndex | ||||
GetXPBlockByIndex | LDataStore* This | Return newly created LXPBlock constructed with the block with index inIndex. Caller is responsible of dellocating the returned object using LXPBlock_Delete. |
LXPBlock* |
- |
LDataStore_TIdx inIndex | ||||
GetData | LDataStore* This | - | void* pointer to the data segment. |
- |
GetSize | LDataStore* This | - | ui4 size of the data segment. |
- |
GetMap | LDataStore* This | - | void* pointer to the data map segment. |
- |
GetMapSize | LDataStore* This | - | ui4 size of the data segment. |
- |
GetBlocksCount | LDataStore* This | - | ui4 number of blocks in the data segment. |
- |
GetXPBlock | LDataStore* This | Read data from LDataStore and create a new LXPBlock object. Caller is responsible of dellocating the returned object using LXPBlock_Delete. | LXPBlock* pointer to the new LXPBlock. |
- |