SEDNL  .
Simple Event Driven Network Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | List of all members
SedNL::RingBuf Class Reference

A ring buffer, for implementation purpose. More...

#include <RingBuf.hpp>

Public Member Functions

 RingBuf (unsigned int size) throw (std::bad_alloc)
 Build a ring buffer of fixed size size.
 
bool put (const char *string, unsigned int length) noexcept
 Try tu put length characters into the buffer. More...
 
unsigned int size () const noexcept
 Return the buffer size. More...
 
unsigned int length () const noexcept
 Calculate the length used. More...
 
void reset () noexcept
 Reset the buffer to length 0.
 
bool pick_event (Event &event) noexcept
 Try to read a full event from the buffer. More...
 

Detailed Description

A ring buffer, for implementation purpose.

You probably won't have to use it, although you are modifying SedNL's code.

Definition at line 42 of file RingBuf.hpp.

Member Function Documentation

unsigned int SedNL::RingBuf::length ( ) const
inlinenoexcept

Calculate the length used.

Returns
Length used.

Definition at line 38 of file RingBuf.ipp.

bool SedNL::RingBuf::pick_event ( Event event)
noexcept

Try to read a full event from the buffer.

Build an event objet from the data. Erase the data from the buffer, and return the new event throught event. If it fails, it do not modify event.

Returns
True if new event stored in event, False otherwise.
bool SedNL::RingBuf::put ( const char *  string,
unsigned int  length 
)
noexcept

Try tu put length characters into the buffer.

Returns
False if failed (unmodified buffer), True otherwise.
unsigned int SedNL::RingBuf::size ( ) const
inlinenoexcept

Return the buffer size.

Returns
Size available.

Definition at line 26 of file RingBuf.ipp.


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