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

  • CSensrvChannelBuffer

Constructor & Destructor Documentation

CSensrvChannelBuffer(TInt, TInt)

CSensrvChannelBuffer(TIntaItemSize,
TIntaBufferLength
)[private]

C++ constructor

Since
S60 5.0

Parameters

TInt aItemSizeSize of single buffered item in bytes
TInt aBufferLengthNumber 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::TSensrvChannelListenerStateaState
)

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 * aListenerPointer to the listener.
TSensrvTailIndexItem *& aTailItemReturns pointer to tail item that can be supplied to other methods.
CSensrvChannelListener::TSensrvChannelListenerState aStatechannel listener state.

CancelFreeBlock()

voidCancelFreeBlock()

Cancels any outstanding free block request Called by SSY thread.

Since
S60 5.0

ConstructL()

voidConstructL()[private]

2nd phase of construction

Since
S60 5.0

GetConditionData(TSensrvTailIndexItem *, CSensrvChannelListener::TChannelDataParts &)

voidGetConditionData(TSensrvTailIndexItem *aTailItem,
CSensrvChannelListener::TChannelDataParts &aDataParts
)

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

Since
S60 5.0

Parameters

TSensrvTailIndexItem * aTailItemPointer to the tail item.
CSensrvChannelListener::TChannelDataParts & aDataPartsReference 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(TIntaCount)

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

Since
S60 5.0

Parameters

TInt aCountNumber of items to get free block for.

GetInitialMessageData(CSensrvChannelListener::TChannelDataMessage &)

voidGetInitialMessageData(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 & aMessageDataReference 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)

voidGetMessageData(TSensrvTailIndexItem *aTailItem,
CSensrvChannelListener::TChannelDataMessage &aMessageData,
TIntaCount
)

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 * aTailItemPointer to the tail item.
CSensrvChannelListener::TChannelDataMessage & aMessageDataReference to message data that is filled. Note that the data is only guaranteed valid as long as proxy's mutex is not signaled.
TInt aCountMaximum number of data items to write.

GetTailIndex(CSensrvChannelListener *)

TInt GetTailIndex(CSensrvChannelListener *aListener)[private]

Gets tail index for listener.

Since
S60 5.0

Parameters

CSensrvChannelListener * aListenerPointer to the listener.

InvalidateRange(TInt)

voidInvalidateRange(TIntaCount)[private]

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

Since
S60 5.0

Parameters

TInt aCountNumber 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(TIntaItemSize,
TIntaBufferLength
)[static]

Two phase constructor

Since
S60 5.0
Exceptions
KErrNoMemory

Out of memory

Parameters

TInt aItemSizeSize of single buffered item in bytes
TInt aBufferLengthNumber of items that need to be buffered.

RemoveListener(CSensrvChannelListener *)

voidRemoveListener(CSensrvChannelListener *aListener)

Removes a listener tail index. Called by server thread.

Since
S60 5.0

Parameters

CSensrvChannelListener * aListenerPointer to the listener.

UpdateDataAvailable(TSensrvTailIndexItem &, TBool)

voidUpdateDataAvailable(TSensrvTailIndexItem &aTailItem,
TBoolaMoreData
)[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 & aTailItemReference to the tail item.
TBool aMoreDataIf ETrue, indicates that update is potentially increasing the amount of data. If false, the update is potentially decreasing the amount of data.

WroteBlock(TInt)

voidWroteBlock(TIntaCount)

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

Since
S60 5.0

Parameters

TInt aCountNumber 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.