Using CCirBuf

This document describes how to use CCirBuf.

Before adding/removing objects

The buffer itself is not allocated until CCirBufBase::SetLengthL() is called. Therefore, the first steps must always be to construct the CCirBuf object and then call its CCirBufBase::SetLengthL() member function.

Also note that SetLengthL() can leave so it's useful to call it under a trap harness.

class Test
 {
public:
 Test(){a=b=0;}
 Test(TInt anInt){a=b=anInt;}
private
 TInt a;
 TInt b;
 };

CCirBuf<Test>* cbInt=new CCirBuf<Test>;
TRAPD(ret,cbInt->SetLengthL(3));            // max capacity is 3
                                            // and allocates buffer
Test one(1);
Test two(2);
...
cbInt->Add(&one);     // Can now start adding/removing objects
...
delete cbInt;