ADTF
cSampleQueue

A simple Sample Queue that hold Samples in a sorted way by time. More...

Inheritance diagram for cSampleQueue:
[legend]

Public Member Functions

 cSampleQueue (tTimeStamp tmTimeRange, size_t szMaxSize, bool bClearOnTimeJumps=false)
 Constructor. More...
 
virtual ~cSampleQueue ()
 Destructor.
 
tResult Push (const iobject_ptr< ISample > &pSample)
 
tResult Pop (iobject_ptr< ISample > &pSample)
 
tResult Pop ()
 
tResult Top (iobject_ptr< ISample > &pSample)
 
size_t GetSize ()
 
bool Empty ()
 
tResult Get (iobject_ptr< ISample > &pSample, tTimeStamp tmTime, tTimeStamp tmDeltaT, uint32_t ui32GetMethod=SQG_GetLast)
 
tResult RegisterQueueEventSink (ISampleQueueEventSink *pQueueEventSink)
 
tResult UnregisterQueueEventSink (const ISampleQueueEventSink *pQueueEventSink)
 
tResult GetSettings (tTimeStamp &tmTimeRange, size_t &szSizeRange) const
 
tResult SetSettings (const tTimeStamp tmTimeRange, const size_t szSizeRange)
 
void GetTimes (tTimeStamp &tmFirst, tTimeStamp &tmLast) const
 
tResult Clear ()
 Clears the SampleQueue. More...
 
tResult SetRanges (tTimeStamp tmTimeRange, size_t szMaxSize=0)
 Set The Sample Queue Ranges (sizes). More...
 
tResult HandleEvent (ucom::IEventSource *pSource, void *pvEventData)
 
- Public Member Functions inherited from object< ISampleQueue >
tResult GetInterface (const char *i_strIID, void *&o_pInterface) override
 Query interfaces on an object. More...
 
tResult GetInterface (const char *i_strIID, const void *&o_pInterface) const override
 Provides const correct interface querying. More...
 
void Destroy () const override
 Destruct and deallocate instantiations of type IObject. More...
 
- Public Member Functions inherited from IObject
 ADTF_IID (IObject, "object.ant.ucom.adtf.iid")
 Marks the IObject to be castable with the ucom_cast() More...
 

Protected Types

typedef std::multimap< adtf::base::tNanoSeconds, adtf::ucom::ant::object_ptr< ISample > > tSampleQueue
 Sample queue is organized as multi set.
 

Protected Member Functions

tResult ClearEventList ()
 Clear all buffered queue events. More...
 
tResult GetNearest2 (iobject_ptr< ISample > &pSampleOlder, iobject_ptr< ISample > &pSampleNewer, tTimeStamp tmTime)
 Search the two samples which are nearest to a given timestamp. More...
 
tResult GetNearest (iobject_ptr< ISample > &pSample, tTimeStamp tmTime, tTimeStamp tmDeltaT)
 Get the sample which is nearest to a given timestamp. More...
 
tResult GetNearestOlder (iobject_ptr< ISample > &pSample, tTimeStamp tmTime, tTimeStamp tmDeltaT)
 Get the sample which is nearest to and older than a given timestamp. More...
 
tResult GetNearestNewer (iobject_ptr< ISample > &ppSample, tTimeStamp tmTime, tTimeStamp tmDeltaT)
 Get the sample which is nearest to and newer than a given timestamp. More...
 
tResult FireEvent (uint32_t ui32Event, int nParam1, int nParam2)
 Fires the Event to all registered ISampleQueueEventSink. More...
 
- Protected Member Functions inherited from IObject
 ~IObject ()=default
 Protected destructor --> Use implemented Destroy() instead of delete!
 

Protected Attributes

adtf::base::tNanoSeconds m_tmTimeRange
 Time range of the samples in the queue.
 
size_t m_szMaxSize
 Maximum size of queue.
 
bool m_bError
 Error indicator.
 
bool m_bTimeStampsInitialized
 m_tmFirstTime and m_tmLastTime initialized?
 
adtf::base::tNanoSeconds m_tmFirstTime
 First timestamp in queue.
 
adtf::base::tNanoSeconds m_tmLastTime
 Last timestamp in queue.
 
std::recursive_mutex m_oEventListLocked
 Event list lock - RAII-pattern.
 
std::list< ISampleQueueEventSink * > m_lstQueueEventReceiver
 Event receivers.
 
bool m_bFireEvents
 Fire events?
 
int m_nClearingQueueCount
 Clearing queue count.
 
adtf::ucom::object_ptr< ISamplem_pLastSample
 Last sample of the queue.
 
std::shared_mutex m_oQueueReadWriteLock
 Queue lock.
 
tSampleQueue m_qSamples
 The sample queue.
 

Private Member Functions

tResult InternalPop (iobject_ptr< ISample > &pSample)
 

Detailed Description

A simple Sample Queue that hold Samples in a sorted way by time.

Please note that these queues do not react on runlevel or filter state changes. So you have to clear them manually in your cFilter::Start or cFilter::Stop methods.

Definition at line 52 of file samplequeue.h.

Constructor & Destructor Documentation

◆ cSampleQueue()

cSampleQueue ( tTimeStamp  tmTimeRange,
size_t  szMaxSize,
bool  bClearOnTimeJumps = false 
)

Constructor.

When one of the parameter is set to zero, only the non-zero parameter is observed.

Parameters
[in]tmTimeRangeThe maximum time difference between the first and the last sample in the queue. (in micro seconds) If this is exceeded, the first samples in the queue will be dropped until the length of the queue (timespan) fits in this range again. 0 = no limit.
[in]szMaxSizeThe maximum size of the queue (number of samples). If this is exceeded, the first samples in the queue will be dropped until the length of the queue is equal to this value. 0 = no limit.
[in]bClearOnTimeJumpsWhether or not the queue should listen for time jump events and clear itself when those occur. Note that in most cases it is better to handle these jumps at a higher level (Filter, etc.) to prevent side effects when the time jumps during processing of the queue.
Attention
At least one of the two parameters tmTimeRange or szMaxSize has to be greater 0. Otherwise the queue is not initialized.

Member Function Documentation

◆ Clear()

tResult Clear ( )

Clears the SampleQueue.

This will clear the SampleQueue and unrefs all inserted Samples.

Returns
Standard Result Code

◆ ClearEventList()

tResult ClearEventList ( )
protected

Clear all buffered queue events.

Returns
Standard Result Code

◆ FireEvent()

tResult FireEvent ( uint32_t  ui32Event,
int  nParam1,
int  nParam2 
)
protected

Fires the Event to all registered ISampleQueueEventSink.

Parameters
ui32Event[in] The event identifier (ISampleQueueEventSink::tSampleQueueEvent).
nParam1[in] User parameter 1
nParam2[in] User parameter 2
Returns
Standard Result Code

◆ GetNearest()

tResult GetNearest ( iobject_ptr< ISample > &  pSample,
tTimeStamp  tmTime,
tTimeStamp  tmDeltaT 
)
protected

Get the sample which is nearest to a given timestamp.

For the Sample parameter ppSample it is necessary to use a ucom::ant::iobject_ptr of ISample class.

Parameters
pSample[out] The nearest sample
tmTime[in] The timestamp
tmDeltaT[in] The maximum deviation from tmTime that the sample is allowed to have
Returns
Standard Result Code

◆ GetNearest2()

tResult GetNearest2 ( iobject_ptr< ISample > &  pSampleOlder,
iobject_ptr< ISample > &  pSampleNewer,
tTimeStamp  tmTime 
)
protected

Search the two samples which are nearest to a given timestamp.

For the Sample parameters ppSampleOlder and ppSampleNewer it is necessary to use a ucom::ant::iobject_ptr of ISample class.

Parameters
pSampleOlder[out] The nearest sample which is older than tmTime
pSampleNewer[out] The nearest sample which is newer than tmTime
tmTime[in] The timestamp
Returns
Standard Result Code

◆ GetNearestNewer()

tResult GetNearestNewer ( iobject_ptr< ISample > &  ppSample,
tTimeStamp  tmTime,
tTimeStamp  tmDeltaT 
)
protected

Get the sample which is nearest to and newer than a given timestamp.

For the Sample parameter ppSample it is necessary to use a ucom::ant::iobject_ptr of ISample class.

Parameters
ppSample[out] The nearest sample
tmTime[in] The timestamp
tmDeltaT[in] The maximum deviation from tmTime that the sample is allowed to have
Returns
Standard Result Code

◆ GetNearestOlder()

tResult GetNearestOlder ( iobject_ptr< ISample > &  pSample,
tTimeStamp  tmTime,
tTimeStamp  tmDeltaT 
)
protected

Get the sample which is nearest to and older than a given timestamp.

Parameters
pSample[out] The nearest sample
tmTime[in] The timestamp
tmDeltaT[in] The maximum deviation from tmTime that the sample is allowed to have
Returns
Standard Result Code

◆ SetRanges()

tResult SetRanges ( tTimeStamp  tmTimeRange,
size_t  szMaxSize = 0 
)

Set The Sample Queue Ranges (sizes).

Please see the documentation of the constructor.

Attention
At least one of the two parameters tmTimeRange or szMaxSize has to be greater 0. Otherwise the queue is not initialized.
Parameters
tmTimeRange[in] Time range.
szMaxSize[in] Maximum size.
Returns
Standard Result Code