# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NLMISC::CBufFIFO Class Reference

This class is a dynamic size FIFO that contains variable size uint8 buffer. More...

#include <buf_fifo.h>

List of all members.

Public Methods

 CBufFIFO ()
 ~CBufFIFO ()
void push (const std::vector< uint8 > &buffer)
 Push 'buffer' in the head of the FIFO. More...

void push (const NLMISC::CMemStream &buffer)
void push (const uint8 *buffer, uint32 size)
void push (const std::vector< uint8 > &buffer1, const std::vector< uint8 > &buffer2)
 Concate and push 'buffer1' and buffer2 in the head of the FIFO. The goal is to avoid a copy. More...

void front (std::vector< uint8 > &buffer)
 Get the buffer in the tail of the FIFO and put it in 'buffer'. More...

void front (NLMISC::CMemStream &buffer)
void front (uint8 *&buffer, uint32 &size)
uint8 frontLast ()
 This function returns the last byte of the front message It is used by the network to know a value quickly without doing front(). More...

void pop ()
 Pop the buffer in the tail of the FIFO. More...

void resize (uint32 size)
 Set the size of the FIFO buffer in byte. More...

bool empty ()
 Return true if the FIFO is empty. More...

void clear ()
 Erase the FIFO. More...

uint32 size ()
 Returns the size of the FIFO. More...

void display ()
 display the FIFO to stdout (used to debug the FIFO). More...

void displayStats ()
 display the FIFO statistics (speed, nbcall, etc...) to stdout. More...


Private Types

typedef uint32 TFifoSize

Private Methods

bool canFit (uint32 size)

Private Attributes

uint8_Buffer
uint32 _BufferSize
bool _Empty
uint8_Head
uint8_Tail
uint8_Rewinder
uint32 _BiggestBlock
uint32 _SmallestBlock
uint32 _BiggestBuffer
uint32 _SmallestBuffer
uint32 _Pushed
uint32 _Fronted
uint32 _Resized
TTicks _PushedTime
TTicks _FrontedTime
TTicks _ResizedTime


Detailed Description

This class is a dynamic size FIFO that contains variable size uint8 buffer.

It's used in the layer1 network for storing temporary messages. You can resize the internal FIFO buffer if you know the average size of data you'll put in it. It have the same behavior as STL so if the buffer is full the size will be automatically increase by 2.

        CBufFIFO fifo;
        fifo.resize(10000);
        vector<uint8> vec;
        vec.resize(rand()%256);
        memset (&(vec[0]), '-', vec.size());
        // push the vector
        fifo.push(vec);
        // display the fifo
        fifo.display();
        vector<uint8> vec2;
        // get the vector
        fifo.pop(vec2);
Author:
Vianney Lecroart , Nevrax France
Date:
2001

Definition at line 64 of file buf_fifo.h.


Member Typedef Documentation

typedef uint32 NLMISC::CBufFIFO::TFifoSize [private]
 

Definition at line 117 of file buf_fifo.h.

Referenced by front, frontLast, pop, and push.


Constructor & Destructor Documentation

NLMISC::CBufFIFO::CBufFIFO  
 

Definition at line 39 of file buf_fifo.cpp.

References _BiggestBlock, _BiggestBuffer, _Fronted, _FrontedTime, _Pushed, _PushedTime, _Resized, _ResizedTime, _SmallestBlock, and _SmallestBuffer.

NLMISC::CBufFIFO::~CBufFIFO  
 

Definition at line 54 of file buf_fifo.cpp.

References _Buffer, and nldebug.


Member Function Documentation

bool NLMISC::CBufFIFO::canFit uint32    size [private]
 

Definition at line 590 of file buf_fifo.cpp.

References _Buffer, _BufferSize, _Head, _Rewinder, _Tail, empty, nldebug, nlstop, and size.

Referenced by push.

void NLMISC::CBufFIFO::clear  
 

Erase the FIFO.

Definition at line 388 of file buf_fifo.cpp.

References _Buffer, _Empty, _Head, _Rewinder, and _Tail.

void NLMISC::CBufFIFO::display  
 

display the FIFO to stdout (used to debug the FIFO).

Definition at line 524 of file buf_fifo.cpp.

References _Buffer, _BufferSize, _Head, _Rewinder, _Tail, NLMISC::DebugLog, size, and NLMISC::smprintf.

Referenced by front, pop, push, and resize.

void NLMISC::CBufFIFO::displayStats  
 

display the FIFO statistics (speed, nbcall, etc...) to stdout.

Definition at line 510 of file buf_fifo.cpp.

References _BiggestBlock, _BiggestBuffer, _Fronted, _FrontedTime, _Pushed, _PushedTime, _Resized, _ResizedTime, _SmallestBlock, _SmallestBuffer, and nlinfo.

bool NLMISC::CBufFIFO::empty   [inline]
 

Return true if the FIFO is empty.

Definition at line 100 of file buf_fifo.h.

References _Empty.

Referenced by canFit, NLNET::CBufSock::flush, front, frontLast, pop, resize, and size.

void NLMISC::CBufFIFO::front uint8 *&    buffer,
uint32   size
 

Definition at line 343 of file buf_fifo.cpp.

References _Buffer, _Fronted, _FrontedTime, _Rewinder, _Tail, display, empty, nldebug, nlwarning, size, TFifoSize, and NLMISC::TTicks.

void NLMISC::CBufFIFO::front NLMISC::CMemStream   buffer
 

Definition at line 285 of file buf_fifo.cpp.

References NLMISC::CMemStream::clear, NLMISC::CMemStream::fill, front, and size.

void NLMISC::CBufFIFO::front std::vector< uint8 > &    buffer
 

Get the buffer in the tail of the FIFO and put it in 'buffer'.

Definition at line 226 of file buf_fifo.cpp.

References size.

Referenced by NLNET::CBufSock::flush, and front.

uint8 NLMISC::CBufFIFO::frontLast  
 

This function returns the last byte of the front message It is used by the network to know a value quickly without doing front().

Definition at line 196 of file buf_fifo.cpp.

References _Buffer, _Rewinder, _Tail, empty, nldebug, nlwarning, size, and TFifoSize.

void NLMISC::CBufFIFO::pop  
 

Pop the buffer in the tail of the FIFO.

Definition at line 157 of file buf_fifo.cpp.

References _Buffer, _Empty, _Head, _Rewinder, _Tail, display, empty, nldebug, nlwarning, size, and TFifoSize.

Referenced by NLNET::CBufSock::flush.

void NLMISC::CBufFIFO::push const std::vector< uint8 > &    buffer1,
const std::vector< uint8 > &    buffer2
 

Concate and push 'buffer1' and buffer2 in the head of the FIFO. The goal is to avoid a copy.

Definition at line 106 of file buf_fifo.cpp.

References _BiggestBlock, _BufferSize, _Empty, _Head, _Pushed, _PushedTime, _SmallestBlock, canFit, display, nlassert, nldebug, resize, size, TFifoSize, and NLMISC::TTicks.

void NLMISC::CBufFIFO::push const uint8   buffer,
uint32    size
 

Definition at line 65 of file buf_fifo.cpp.

References _BiggestBlock, _BufferSize, _Empty, _Head, _Pushed, _PushedTime, _SmallestBlock, canFit, display, nlassert, nldebug, resize, size, TFifoSize, and NLMISC::TTicks.

void NLMISC::CBufFIFO::push const NLMISC::CMemStream   buffer [inline]
 

Definition at line 74 of file buf_fifo.h.

References NLMISC::CMemStream::buffer, NLMISC::CMemStream::length, and push.

void NLMISC::CBufFIFO::push const std::vector< uint8 > &    buffer [inline]
 

Push 'buffer' in the head of the FIFO.

Definition at line 72 of file buf_fifo.h.

Referenced by push, and NLNET::CBufSock::pushBuffer.

void NLMISC::CBufFIFO::resize uint32    size
 

Set the size of the FIFO buffer in byte.

Definition at line 422 of file buf_fifo.cpp.

References _BiggestBuffer, _Buffer, _BufferSize, _Head, _Resized, _ResizedTime, _Rewinder, _SmallestBuffer, _Tail, display, empty, nlassert, nldebug, nlerror, nlwarning, size, size, and NLMISC::TTicks.

Referenced by push.

uint32 NLMISC::CBufFIFO::size  
 

Returns the size of the FIFO.

Definition at line 395 of file buf_fifo.cpp.

References _Buffer, _BufferSize, _Head, _Rewinder, _Tail, empty, nlassert, and nlstop.

Referenced by canFit, display, front, frontLast, pop, push, resize, and NLNET::CBufSock::update.


Member Data Documentation

uint32 NLMISC::CBufFIFO::_BiggestBlock [private]
 

Definition at line 140 of file buf_fifo.h.

Referenced by CBufFIFO, displayStats, and push.

uint32 NLMISC::CBufFIFO::_BiggestBuffer [private]
 

Definition at line 142 of file buf_fifo.h.

Referenced by CBufFIFO, displayStats, and resize.

uint8* NLMISC::CBufFIFO::_Buffer [private]
 

Definition at line 120 of file buf_fifo.h.

Referenced by canFit, clear, display, front, frontLast, pop, resize, size, and ~CBufFIFO.

uint32 NLMISC::CBufFIFO::_BufferSize [private]
 

Definition at line 122 of file buf_fifo.h.

Referenced by canFit, display, push, resize, and size.

bool NLMISC::CBufFIFO::_Empty [private]
 

Definition at line 125 of file buf_fifo.h.

Referenced by clear, empty, pop, and push.

uint32 NLMISC::CBufFIFO::_Fronted [private]
 

Definition at line 145 of file buf_fifo.h.

Referenced by CBufFIFO, displayStats, and front.

TTicks NLMISC::CBufFIFO::_FrontedTime [private]
 

Definition at line 148 of file buf_fifo.h.

Referenced by CBufFIFO, displayStats, and front.

uint8* NLMISC::CBufFIFO::_Head [private]
 

Definition at line 128 of file buf_fifo.h.

Referenced by canFit, clear, display, pop, push, resize, and size.

uint32 NLMISC::CBufFIFO::_Pushed [private]
 

Definition at line 144 of file buf_fifo.h.

Referenced by CBufFIFO, displayStats, and push.

TTicks NLMISC::CBufFIFO::_PushedTime [private]
 

Definition at line 147 of file buf_fifo.h.

Referenced by CBufFIFO, displayStats, and push.

uint32 NLMISC::CBufFIFO::_Resized [private]
 

Definition at line 146 of file buf_fifo.h.

Referenced by CBufFIFO, displayStats, and resize.

TTicks NLMISC::CBufFIFO::_ResizedTime [private]
 

Definition at line 149 of file buf_fifo.h.

Referenced by CBufFIFO, displayStats, and resize.

uint8* NLMISC::CBufFIFO::_Rewinder [private]
 

Definition at line 132 of file buf_fifo.h.

Referenced by canFit, clear, display, front, frontLast, pop, resize, and size.

uint32 NLMISC::CBufFIFO::_SmallestBlock [private]
 

Definition at line 141 of file buf_fifo.h.

Referenced by CBufFIFO, displayStats, and push.

uint32 NLMISC::CBufFIFO::_SmallestBuffer [private]
 

Definition at line 143 of file buf_fifo.h.

Referenced by CBufFIFO, displayStats, and resize.

uint8* NLMISC::CBufFIFO::_Tail [private]
 

Definition at line 130 of file buf_fifo.h.

Referenced by canFit, clear, display, front, frontLast, pop, resize, and size.


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