Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: e32base.h
Link against: euser.lib

Class CCirBuf

class CCirBuf<class T> : public CCirBufBase;

Support

Supported from 5.0

Description

A circular buffer containing objects of a type defined by the template parameter.

Derivation

CBaseBase class for all classes to be instantiated on the heap
CCirBufA circular buffer containing objects of a type defined by the template parameter
CCirBufBaseBase class for circular buffers

Defined in CCirBuf:
Add(), CCirBuf(), Remove()

Inherited from CBase:
operator new()

Inherited from CCirBufBase:
Count(), Length(), Reset(), SetLengthL()


Construction


CCirBuf()

CCirBuf();

Description

Default C++ constructor.

The size of each object in the buffer is fixed and is the length of the class passed as the template parameter. The length of the template class must be non-zero otherwise the constructor raises an E32USER-CBase 72 panic.

[Top]


Adding objects to the circular buffer


Add()

TInt Add(const T* aPtr);

Description

Adds a single object to the circular buffer. The object is of type class T and is only added if there is space available.

Notes:

A call to CCirBufBase::SetLengthL() must already have been made before calling this function, otherwise an E32USER-CBase 74 panic is raised.

Parameters

const T* aPtr

A pointer to the object of type class T to be added to the circular buffer

Return value

TInt

1 if the object is successfully added. 0 if the object cannot be added because the circular buffer is full.


Add()

TInt Add(const T* aPtr,TInt aCount);

Description

Adds multiple objects to the circular buffer. The function attempts to add aCount objects of type class T. The objects are only added if there is space available.

Note:

A call to CCirBufBase::SetLengthL() must already have been made before calling Add(), otherwise an E32USER-CBase 74 panic is raised

Parameters

const T* aPtr

A pointer to a set of contiguous objects of type class T to be added to the circular buffer.

TInt aCount

The number of objects to be added to the circular buffer. This must be a positive value otherwise the function raises a E32USER-CBase 75 panic.

Return value

TInt

The number of objects successfully added to the buffer. This value may be less than the number requested and can range from 0 to aCount.

[Top]


Removing objects from the circular buffer


Remove()

TInt Remove(T* aPtr);

Description

Removes a single object from the circular buffer. The object is of type class T and can only be removed if there are objects in the buffer.

A binary copy of the object is made to aPtr.

Parameters

T* aPtr

A pointer to an object of type class T supplied by the caller.

Return value

TInt

1 if an object is successfully removed. 0 if an object cannot be removed because the circular buffer is empty.


Remove()

TInt Remove(T* aPtr,TInt aCount);

Description

Removes multiple objects from the circular buffer. The function attempts to remove aCount objects of type class T. Objects can only be removed if there are objects in the buffer

A binary copy of the objects is made to aPtr.

Parameters

T* aPtr

A pointer to contiguous memory able to hold aCount class T objects, supplied by the caller.

TInt aCount

The number of objects to be removed from the circular buffer. This must be a positive value otherwise an E32USER-CBase 76 panic is raised.

Return value

TInt

The number of objects successfully removed from the buffer. This value may be less than the number requested and can range from 0 to aCount.