CSensrvChannelBuffer Class Reference

class CSensrvChannelBuffer : public CBase

Implements channel buffer related handling.

Channel buffer is a ring buffer with a couple of special twists:
  • There can be multiple tail pointers (one for each client that is listening to the channel).

  • New data is written by SSY or sensor driver directly to buffer, so any pointer given for writing must have at enough continuous space to fit n items (specified when new pointer is requested). -> This leads to situations where end of the buffer contains no valid data, so there is an end index to indicate end of valid data.

Since
S60 5.0

Inherits from

Constructor & Destructor Documentation

CSensrvChannelBuffer(TInt, TInt)

CSensrvChannelBuffer ( TInt aItemSize,
TInt aBufferLength
) [private]

C++ constructor

Since
S60 5.0

Parameters

TInt aItemSize Size of single buffered item in bytes
TInt aBufferLength Number of items that need to be buffered.

~CSensrvChannelBuffer()

~CSensrvChannelBuffer ( ) [virtual]

Destructor.

Member Functions Documentation

AddListener(CSensrvChannelListener *, TSensrvTailIndexItem *&, CSensrvChannelListener::TSensrvChannelListenerState)

TInt AddListener ( CSensrvChannelListener * aListener,
TSensrvTailIndexItem *& aTailItem,
CSensrvChannelListener::TSensrvChannelListenerState aState
)

Add new listener tail index. Index is initialized to KSensrvChannelBufferUninitializedTail, if there is an outstanding request for data block, or iHeadIndex if not. This is done so that first write of data will be ignored, as it was generated before listening started for this listener.

Called by server thread.

Since
S60 5.0

Parameters

CSensrvChannelListener * aListener Pointer to the listener.
TSensrvTailIndexItem *& aTailItem Returns pointer to tail item that can be supplied to other methods.
CSensrvChannelListener::TSensrvChannelListenerState aState channel listener state.

CancelFreeBlock()

void CancelFreeBlock ( )

Cancels any outstanding free block request Called by SSY thread.

Since
S60 5.0

ConstructL()

void ConstructL ( ) [private]

2nd phase of construction

Since
S60 5.0

GetConditionData(TSensrvTailIndexItem *, CSensrvChannelListener::TChannelDataParts &)

void GetConditionData ( TSensrvTailIndexItem * aTailItem,
CSensrvChannelListener::TChannelDataParts & aDataParts
)

Gets data for condition evaluation and resets condition tail to head index.

Since
S60 5.0

Parameters

TSensrvTailIndexItem * aTailItem Pointer to the tail item.
CSensrvChannelListener::TChannelDataParts & aDataParts Reference to dataparts object is filled. Note that the data is only guaranteed valid as long as proxy's mutex is not signaled.

GetFreeBlock(TInt)

TUint8 * GetFreeBlock ( TInt aCount )

Gets pointer to next free block of n items. Adjusts indexes accordingly. Called by SSY thread.

Since
S60 5.0

Parameters

TInt aCount Number of items to get free block for.

GetInitialMessageData(CSensrvChannelListener::TChannelDataMessage &)

void GetInitialMessageData ( CSensrvChannelListener::TChannelDataMessage & aMessageData )

Gets the initial data item that can be sent to new listerers if there is no data available by GetMessageData() . Called by server thread.

Since
S60 5.0

Parameters

CSensrvChannelListener::TChannelDataMessage & aMessageData Reference to message data that is filled. Note that the data is only guaranteed valid as long as proxy's mutex is not signaled.

GetMessageData(TSensrvTailIndexItem *, CSensrvChannelListener::TChannelDataMessage &, TInt)

void GetMessageData ( TSensrvTailIndexItem * aTailItem,
CSensrvChannelListener::TChannelDataMessage & aMessageData,
TInt aCount
)

Gets data for transaction and adjusts listener tail accordingly. Data written can be less than the specified count, if there is less data available. Called by server thread.

Since
S60 5.0

Parameters

TSensrvTailIndexItem * aTailItem Pointer to the tail item.
CSensrvChannelListener::TChannelDataMessage & aMessageData Reference to message data that is filled. Note that the data is only guaranteed valid as long as proxy's mutex is not signaled.
TInt aCount Maximum number of data items to write.

GetTailIndex(CSensrvChannelListener *)

TInt GetTailIndex ( CSensrvChannelListener * aListener ) [private]

Gets tail index for listener.

Since
S60 5.0

Parameters

CSensrvChannelListener * aListener Pointer to the listener.

InvalidateRange(TInt)

void InvalidateRange ( TInt aCount ) [private]

Invalidates range of items starting from head index. Adjusts valid and tail indexes accordingly.

Since
S60 5.0

Parameters

TInt aCount Number of items to invalidate.

Length()

TInt Length ( ) const [inline]

Gets buffer length Called from server thread

Since
S60 5.0

NewL(TInt, TInt)

CSensrvChannelBuffer * NewL ( TInt aItemSize,
TInt aBufferLength
) [static]

Two phase constructor

Since
S60 5.0
Exceptions
KErrNoMemory

Out of memory

Parameters

TInt aItemSize Size of single buffered item in bytes
TInt aBufferLength Number of items that need to be buffered.

RemoveListener(CSensrvChannelListener *)

void RemoveListener ( CSensrvChannelListener * aListener )

Removes a listener tail index. Called by server thread.

Since
S60 5.0

Parameters

CSensrvChannelListener * aListener Pointer to the listener.

UpdateDataAvailable(TSensrvTailIndexItem &, TBool)

void UpdateDataAvailable ( TSensrvTailIndexItem & aTailItem,
TBool aMoreData
) [private]

Checks how much new data is available for listener. If there is no data amount change, no update is needed.

Since
S60 5.0

Parameters

TSensrvTailIndexItem & aTailItem Reference to the tail item.
TBool aMoreData If ETrue, indicates that update is potentially increasing the amount of data. If false, the update is potentially decreasing the amount of data.

WroteBlock(TInt)

void WroteBlock ( TInt aCount )

Validates block of n items starting from the head index. Adjusts indexes accordingly. Called by SSY thread.

Since
S60 5.0

Parameters

TInt aCount Number of items that were written.

Member Data Documentation

HBufC8 * iBuffer

HBufC8 * iBuffer [private]

Actual buffer. Own.

TInt iBufferLength

TInt iBufferLength [private]

Number of items buffer can hold.

TInt iHeadIndex

TInt iHeadIndex [private]

Indicates cell where SSY will be writing next.

TInt iItemSize

TInt iItemSize [private]

Single buffered data item size

TInt iLatestWrittenItemIndex

TInt iLatestWrittenItemIndex [private]

Index of the latest written data item or KErrNotFound. The item located at this index can be sent to new listeners as initial data if there is nothing else to sent.

TInt iRequestedFreeBlockLength

TInt iRequestedFreeBlockLength [private]

Indicates the length of free block that has been requested.

RPointerArray< TSensrvTailIndexItem > iTailIndexArray

RPointerArray < TSensrvTailIndexItem > iTailIndexArray [private]

Array of listener tail indexes

TInt iValidEndIndex

TInt iValidEndIndex [private]

Indicates first invalid data cell after continuous valid cells. If iHeadIndex == iValidEndIndex, valid buffer space is continuous. If iHeadIndex < iValidEndIndex, buffer has wrapped around.