Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



Location: e32base.h
Link against: euser.lib

Class CCirBufBase

class CCirBufBase : public CBase;

Description

Base class for circular buffers.

The class is part of the implementation of circular buffers and is never instantiated.

The class provides member functions that form part of the interface.

Derivation

Members

Defined in CCirBufBase:
CCirBufBase(), Count(), DoAdd(), DoAdd(), DoRemove(), DoRemove(), Length(), Reset(), SetLengthL(), iCount, iHead, iLength, iPtr, iPtrE, iSize, iTail, ~CCirBufBase()

Inherited from CBase:
Delete(), Extension_(), operator new()


Construction and destruction


~CCirBufBase()

IMPORT_C ~CCirBufBase();

Description

Destructor.

This frees the memory allocated to the buffer.


CCirBufBase()

protected: IMPORT_C CCirBufBase(TInt aSize);

Description

Constructor taking the size of an object within the buffer.

Parameters

TInt aSize

The size of an object in the buffer.

Panic codes

E32USER-CBase

72, if aSize is zero or negative.

[Top]


Member functions


Count()

inline TInt Count() const;

Description

Gets the current number of objects in this circular buffer.

Return value

TInt

The number of objects in this circular buffer. This value can never be greater than the maximum capacity.


Length()

inline TInt Length() const;

Description

Gets the maximum capacity of this circular buffer.

The capacity is the maximum number of elements that the buffer can hold.

Use SetLengthL() to change the capacity of the circular buffer.

Return value

TInt

The maximum capacity of this circular buffer.


SetLengthL()

IMPORT_C void SetLengthL(TInt aLength);

Description

Sets the maximum capacity of this circular buffer, and resets all of the buffer pointers.

The capacity is the maximum number of elements that the buffer can hold.

The buffer itself is allocated as a result of a call to this function. If the function has previously been called, then any existing buffer is freed and any information in it is lost.

Notes:

1. This function must be called before attempting to add any objects to the buffer.

2. The function can leave if there is insufficient memory available to allocate the buffer.

Parameters

TInt aLength

The maximum capacity of the circular buffer.

Panic codes

E32USER-CBase

73, if aLength is zero or negative.


Reset()

IMPORT_C void Reset();

Description

Empties the buffer.


DoAdd()

protected: IMPORT_C TInt DoAdd(const TUint8 *aPtr);

Description

Implementation function for CCirBuf::Add(const T*)

Adds a single object to the circular buffer, but only if there is space available.

Parameters

const TUint8 *aPtr

A pointer to the object to be added.

Return value

TInt

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

Panic codes

E32USER-CBase

74, if a call to CCirBufBase::SetLengthL() has not been made before calling this function.


DoAdd()

protected: IMPORT_C TInt DoAdd(const TUint8 *aPtr, TInt aCount);

Description

Implementation function for CCirBuf::Add(const T*,TInt)

Adds multiple objects to the circular buffer, but only if there is space available.

Parameters

const TUint8 *aPtr

A pointer to a set of contiguous objects to be added.

TInt aCount

The number of objects to be added.

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.

Panic codes

E32USER-CBase

74, if a call to CCirBufBase::SetLengthL() has not been made before calling this function.

E32USER-CBase

75, if aCount is not a positive value.


DoRemove()

protected: IMPORT_C TInt DoRemove(TUint8 *aPtr);

Description

Implementation function for CCirBuf::Remove(T*)

Removes a single object from the circular buffer, but only if there are objects in the buffer.

A binary copy of the object is made to aPtr.

Parameters

TUint8 *aPtr

A pointer to a location 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.


DoRemove()

protected: IMPORT_C TInt DoRemove(TUint8 *aPtr, TInt aCount);

Description

Implementation function for CCirBuf::Remove(T*,TInt)

Attempts to remove aCount objects from the circular buffer, but only if there are objects in the buffer.

A binary copy of the objects is made to aPtr.

Parameters

TUint8 *aPtr

A pointer to a location supplied by the caller capable of holding aCount objects.

TInt aCount

The number of objects to be removed from the circular buffer.

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.

Panic codes

E32USER-CBase

76, if aCount is not a positive value.

[Top]


Member data


iCount

protected: TInt iCount;

Description


iSize

protected: TInt iSize;

Description


iLength

protected: TInt iLength;

Description


iPtr

protected: TUint8 * iPtr;

Description


iPtrE

protected: TUint8 * iPtrE;

Description


iHead

protected: TUint8 * iHead;

Description


iTail

protected: TUint8 * iTail;

Description