Apache log4cxx  Version 0.12.0
log4cxx::helpers::CyclicBuffer Class Reference

CyclicBuffer is used by other appenders to hold instances of LoggingEvent for immediate or deferred display. More...

#include <cyclicbuffer.h>

Public Member Functions

 CyclicBuffer (int maxSize)
 Instantiate a new CyclicBuffer of at most maxSize events. More...
 
 ~CyclicBuffer ()
 
void add (const spi::LoggingEventPtr &event)
 Add an event as the last event in the buffer. More...
 
spi::LoggingEventPtr get (int i)
 Get the ith oldest event currently in the buffer. More...
 
int getMaxSize () const
 
spi::LoggingEventPtr get ()
 Get the oldest (first) element in the buffer. More...
 
int length () const
 Get the number of elements in the buffer. More...
 
void resize (int newSize)
 Resize the cyclic buffer to newSize. More...
 

Detailed Description

CyclicBuffer is used by other appenders to hold instances of LoggingEvent for immediate or deferred display.

This buffer gives read access to any element in the buffer not just the first or last element.

Constructor & Destructor Documentation

◆ CyclicBuffer()

log4cxx::helpers::CyclicBuffer::CyclicBuffer ( int  maxSize)

Instantiate a new CyclicBuffer of at most maxSize events.

The maxSize argument must a positive integer.

Parameters
maxSizeThe maximum number of elements in the buffer.
Exceptions
IllegalArgumentExceptionif maxSize is negative.

◆ ~CyclicBuffer()

log4cxx::helpers::CyclicBuffer::~CyclicBuffer ( )

Member Function Documentation

◆ add()

void log4cxx::helpers::CyclicBuffer::add ( const spi::LoggingEventPtr event)

Add an event as the last event in the buffer.

◆ get() [1/2]

spi::LoggingEventPtr log4cxx::helpers::CyclicBuffer::get ( int  i)

Get the ith oldest event currently in the buffer.

If i is outside the range 0 to the number of elements currently in the buffer, then null is returned.

◆ get() [2/2]

spi::LoggingEventPtr log4cxx::helpers::CyclicBuffer::get ( )

Get the oldest (first) element in the buffer.

The oldest element is removed from the buffer.

◆ getMaxSize()

int log4cxx::helpers::CyclicBuffer::getMaxSize ( ) const
inline

◆ length()

int log4cxx::helpers::CyclicBuffer::length ( ) const
inline

Get the number of elements in the buffer.

This number is guaranteed to be in the range 0 to maxSize (inclusive).

◆ resize()

void log4cxx::helpers::CyclicBuffer::resize ( int  newSize)

Resize the cyclic buffer to newSize.

Exceptions
IllegalArgumentExceptionif newSize is negative.

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