ADTF
Loading...
Searching...
No Matches
adtf::streaming::ant::cSampleQueue Class Reference

#include <samplequeue.h>

Inherits adtf::ucom::catwo::object< ISampleQueue >.

Public Member Functions

 cSampleQueue (tTimeStamp tmTimeRange, size_t szMaxSize, bool bClearOnTimeJumps=false)
 
virtual ~cSampleQueue ()
 
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 ()
 
tResult SetRanges (tTimeStamp tmTimeRange, size_t szMaxSize=0)
 
tResult HandleEvent (ucom::IEventSource *pSource, void *pvEventData)
 
- Public Member Functions inherited from adtf::ucom::catwo::object< ISampleQueue >
tResult GetInterface (const char *i_strIID, void *&o_pInterface) override
 Query interfaces on an object.
 
tResult GetInterface (const char *i_strIID, const void *&o_pInterface) const override
 Provides const correct interface querying.
 
void Destroy () const override
 Switch from non-virtual destructor to virtual destructor.
 
tResult GetInterface (const char *i_strIID, void *&o_pInterface) override
 Query interfaces on an object.
 
tResult GetInterface (const char *i_strIID, const void *&o_pInterface) const override
 Provides const correct interface querying.
 
void Destroy () const override
 Switch from non-virtual destructor to virtual destructor.
 
tResult GetInterface (const char *i_strIID, void *&o_pInterface) override
 Query interfaces on an object.
 
tResult GetInterface (const char *i_strIID, const void *&o_pInterface) const override
 Provides const correct interface querying.
 
void Destroy () const override
 Switch from non-virtual destructor to virtual destructor.
 
- Public Member Functions inherited from adtf::ucom::ant::IObject
 ADTF_IID (IObject, "object.ant.ucom.adtf.iid")
 

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 ()
 
tResult GetNearest2 (iobject_ptr< ISample > &pSampleOlder, iobject_ptr< ISample > &pSampleNewer, tTimeStamp tmTime)
 
tResult GetNearest (iobject_ptr< ISample > &pSample, tTimeStamp tmTime, tTimeStamp tmDeltaT)
 
tResult GetNearestOlder (iobject_ptr< ISample > &pSample, tTimeStamp tmTime, tTimeStamp tmDeltaT)
 
tResult GetNearestNewer (iobject_ptr< ISample > &ppSample, tTimeStamp tmTime, tTimeStamp tmDeltaT)
 
tResult FireEvent (uint32_t ui32Event, int nParam1, int nParam2)
 
- Protected Member Functions inherited from adtf::ucom::ant::IObject
 ~IObject ()=default
 Protected destructor --> Only the final implementation can be destroyed!
 

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.
 

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.

Constructor & Destructor Documentation

◆ cSampleQueue()

adtf::streaming::ant::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.

◆ ~cSampleQueue()

virtual adtf::streaming::ant::cSampleQueue::~cSampleQueue ( )
virtual

Destructor

Member Function Documentation

◆ Clear()

tResult adtf::streaming::ant::cSampleQueue::Clear ( )

Clears the SampleQueue. This will clear the SampleQueue and unrefs all inserted Samples.

Returns
Standard Result Code

◆ ClearEventList()

tResult adtf::streaming::ant::cSampleQueue::ClearEventList ( )
protected

Clear all buffered queue events

Returns
Standard Result Code

◆ FireEvent()

tResult adtf::streaming::ant::cSampleQueue::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 adtf::streaming::ant::cSampleQueue::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 adtf::streaming::ant::cSampleQueue::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 adtf::streaming::ant::cSampleQueue::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 adtf::streaming::ant::cSampleQueue::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 adtf::streaming::ant::cSampleQueue::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

The documentation for this class was generated from the following file: