LBController¶
This page describes the class LBController
LBBase
objects must have the same number of layers and the same layer size.LBBase
objects.
Schematic representation of an LBController
controlling two LayerBuf
objects and one LayerArrBuf
object.
The red cells in the L2List
denote the nodes of the ACTIVE chain, the red arrows point to the elements in the LayerBuf
objects that are in use.
The green cells in the L2List
denote the nodes of the PASSIVE chain, the white boxes represent currently unused elements.¶
- Code:
Public Methods¶
constructor
¶
LBController(uint iLayerSize);
Creates a LBController with the specified layer size. The layer size must ve a power of two.
iLayerSize
Layer size.
constructor
¶
LBController();
Empty constructor.
destructor
¶
~LBController();
The destructor.
init
¶
int init(int iLayerSize);
Initializes the LBController with the specified layer size. The layer size must ve a power of two.
iLayerSize
Layer size.
addBuffer
¶
int addBuffer(LBBase *pLB);
Adds a LBBase
object to be managed. This object must have the same layer size as the one the LBController
was created for.
Furthermore, it must have the same number of layers as any LBBase
object that has been addered before.
pLB
The LBBase object to be added.
Returns 0 on success, or negative value at failure.
removeBuffer
¶
int removeBuffer(LBBase *pLB);
Remove the specified LBBase.
pLB
The LBBase object to be removed.
Returns 0 on success, or negative value at failure.
addLayer
¶
int addLayer();
Add a new layer to the managed buffers. This entails adding a new layer to each buffer and to add an L2List object for it for the new layer.
Returns 0 on success, or negative value at failure.
removeLayer
¶
int removeLayer(uint iLayer);
Remove the specified layer from all buffers, as well as the L2List needed for it.
Returns 0 on success, or negative value at failure.
getFreeIndex
¶
uint getFreeIndex();
Returns the first free index in the buffers.
deleteElement
¶
int deleteElement(uint lIndex);
Deletes element with given index (i.e. move the correponding node from the ACTIVE to the PASSIVE chain of the L2List)
iIndex
Index of the element to be removed.
Returns 0 on success, or negative value at failure.
int compactData
¶
int compactData();
Compactify all buffers.
Returns 0 on success, or negative value at failure.
clear
¶
void clear();
Clear all ‘LBBase
objects (i.e. mark their elements as PASSIVE in the L2List
).
reserveSpace2
¶
uint reserveSpace2(uint iNum);
Reserve iNum spaces in each buffer. In fact only L2List is manipulated for this.
iNum
Number of spaces to reserve.
Returns index to first of the reserved element.
getFirstIndex
¶
int getFirstIndex(uchar uState) const;
Get the first element of the specified chain.
uState
Either
LBController::ACTIVE
orLBController::PASSIVE
Retuns the first element of the specified chain.
getNextIndex
¶
int getNextIndex(uchar uState, int iCur) const;
Get the next element after iCur
in the specified chain.
uState
Either
LBController::ACTIVE
orLBController::PASSIVE
iCur
Index of element of interest.
Returns the next element after iCur
in the specified chain.
getLastIndex
¶
int getLastIndex(uchar uState) const;
Get the last element of the specified chain.
uState
Either
LBController::ACTIVE
orLBController::PASSIVE
Retuns the last element of the specified chain.
getLayerSize
¶
uint getLayerSize() const;
Returns the layer size.
getNumLayers
¶
uint getNumLayers() const;
Returns number of layers.
getNumUsed
¶
uint getNumUsed() const;
Returns number used indexes,
getNumFree
¶
uint getNumFree() const;
Returns number of unused indexes.
getNumUsed
¶
uint getNumUsed(int i) const;
Returns number of used elements in layer i.
getNumUnused
¶
uint getNumUnused(int i) const;
Returns number of unused elements in layer i.
getBufSize
¶
int getBufSize(int iDumpMode);
Calculate buffer size required to serialize the LBController with specified dump mode.
iDumpMode
- Mode for dumping.Possible values:
LBController::DUMP_MODE_FLAT
orLBController::DUMP_MODE_SMART
.
serialize
¶
uchar *serialize(uchar *pBuf);
Write the serialized LBController
into the specified buffer.
pBuf
Buffer to serialize into.
Returns pointer to one position after the end of the serialized data.
deserialize
¶
int deserialize(uchar *pBuf);
Creates LBController
from serialized data in pBuf
.
pBuf
Buffer containing serialized
LBController
data.
Returns pointer to one position after the end of the serialized data.