ADTF  3.18.2
samplequeue.h
Go to the documentation of this file.
1 
7 #pragma once
8 #include "sample_intf.h"
9 #include "samplequeue_intf.h"
10 
11 #include <shared_mutex>
12 
13 namespace adtf
14 {
15 namespace streaming
16 {
17 namespace ant
18 {
19 
24 {
32  {
33  if (pSample.Get() != nullptr && pSampleAdd.Get() != nullptr)
34  {
35  return (pSampleAdd.Get()->GetTime() < pSample.Get()->GetTime());
36  }
37  return true;
38  }
39 };
40 
44 #define ADTF_SAMPLEQUEUE_CLASS_VERSION_01 0x01
45 
52 class cSampleQueue :
53  public ucom::catwo::object<ISampleQueue>
54 {
56 
57  public:
73  cSampleQueue(tTimeStamp tmTimeRange, size_t szMaxSize, bool bClearOnTimeJumps = false);
74 
78  virtual ~cSampleQueue();
79 
80  protected:
82  size_t m_szMaxSize;
83  bool m_bError;
84 
88 
89  std::recursive_mutex m_oEventListLocked;
90  std::list<ISampleQueueEventSink*> m_lstQueueEventReceiver;
93 
95  std::shared_mutex m_oQueueReadWriteLock;
96 
97  typedef std::multimap<adtf::base::tNanoSeconds, adtf::ucom::ant::object_ptr<ISample>> tSampleQueue;
99 
100  public: //implements ISampleQueue
101  tResult Push(const iobject_ptr<ISample>& pSample);
102  tResult Pop(iobject_ptr<ISample>& pSample);
103  tResult Pop();
104  tResult Top(iobject_ptr<ISample>& pSample);
105 
106  size_t GetSize();
107  bool Empty();
108 
109  tResult Get(iobject_ptr<ISample>& pSample,
110  tTimeStamp tmTime,
111  tTimeStamp tmDeltaT,
112  uint32_t ui32GetMethod=SQG_GetLast);
113 
114  tResult RegisterQueueEventSink(ISampleQueueEventSink* pQueueEventSink);
115  tResult UnregisterQueueEventSink(const ISampleQueueEventSink* pQueueEventSink);
116 
117  tResult GetSettings(tTimeStamp& tmTimeRange, size_t& szSizeRange) const;
118  tResult SetSettings(const tTimeStamp tmTimeRange, const size_t szSizeRange);
119  void GetTimes(tTimeStamp& tmFirst, tTimeStamp& tmLast) const;
120 
121  public:
128 
138  tResult SetRanges(tTimeStamp tmTimeRange, size_t szMaxSize=0);
139 
140  protected:
157  tResult GetNearest2(iobject_ptr<ISample>& pSampleOlder, iobject_ptr<ISample>& pSampleNewer, tTimeStamp tmTime);
169  tResult GetNearest(iobject_ptr<ISample>& pSample, tTimeStamp tmTime, tTimeStamp tmDeltaT);
179  tResult GetNearestOlder(iobject_ptr<ISample>& pSample, tTimeStamp tmTime, tTimeStamp tmDeltaT);
191  tResult GetNearestNewer(iobject_ptr<ISample>& ppSample, tTimeStamp tmTime, tTimeStamp tmDeltaT);
192 
202  tResult FireEvent(uint32_t ui32Event,
203  int nParam1,
204  int nParam2);
205 
206  public:
207  //not implemented
208  tResult HandleEvent(ucom::IEventSource* pSource, void* pvEventData);
209  private:
210  tResult InternalPop(iobject_ptr<ISample>& pSample);
211 };
212 
213 } //namesapce ant
214 } //namespac streaming
215 } // namespace adtf
The ISampleQueueEventSink provides methods to act upon sample queue events emitted by a sample queue.
A simple Sample Queue that hold Samples in a sorted way by time.
Definition: samplequeue.h:54
int m_nClearingQueueCount
Clearing queue count.
Definition: samplequeue.h:92
tResult GetNearestNewer(iobject_ptr< ISample > &ppSample, tTimeStamp tmTime, tTimeStamp tmDeltaT)
Get the sample which is nearest to and newer than a given timestamp.
bool m_bTimeStampsInitialized
m_tmFirstTime and m_tmLastTime initialized?
Definition: samplequeue.h:85
size_t m_szMaxSize
Maximum size of queue.
Definition: samplequeue.h:82
std::shared_mutex m_oQueueReadWriteLock
Queue lock.
Definition: samplequeue.h:95
tResult Clear()
Clears the SampleQueue.
tResult GetNearest(iobject_ptr< ISample > &pSample, tTimeStamp tmTime, tTimeStamp tmDeltaT)
Get the sample which is nearest to a given timestamp.
std::multimap< adtf::base::tNanoSeconds, adtf::ucom::ant::object_ptr< ISample > > tSampleQueue
Sample queue is organized as multi set.
Definition: samplequeue.h:97
adtf::base::tNanoSeconds m_tmTimeRange
Time range of the samples in the queue.
Definition: samplequeue.h:81
adtf::ucom::object_ptr< ISample > m_pLastSample
Last sample of the queue.
Definition: samplequeue.h:94
adtf::base::tNanoSeconds m_tmLastTime
Last timestamp in queue.
Definition: samplequeue.h:87
std::list< ISampleQueueEventSink * > m_lstQueueEventReceiver
Event receivers.
Definition: samplequeue.h:90
tResult FireEvent(uint32_t ui32Event, int nParam1, int nParam2)
Fires the Event to all registered ISampleQueueEventSink.
std::recursive_mutex m_oEventListLocked
Event list lock - RAII-pattern.
Definition: samplequeue.h:89
tResult GetNearest2(iobject_ptr< ISample > &pSampleOlder, iobject_ptr< ISample > &pSampleNewer, tTimeStamp tmTime)
Search the two samples which are nearest to a given timestamp.
tSampleQueue m_qSamples
The sample queue.
Definition: samplequeue.h:98
tResult GetNearestOlder(iobject_ptr< ISample > &pSample, tTimeStamp tmTime, tTimeStamp tmDeltaT)
Get the sample which is nearest to and older than a given timestamp.
virtual ~cSampleQueue()
Destructor.
tResult SetRanges(tTimeStamp tmTimeRange, size_t szMaxSize=0)
Set The Sample Queue Ranges (sizes).
adtf::base::tNanoSeconds m_tmFirstTime
First timestamp in queue.
Definition: samplequeue.h:86
bool m_bError
Error indicator.
Definition: samplequeue.h:83
cSampleQueue(tTimeStamp tmTimeRange, size_t szMaxSize, bool bClearOnTimeJumps=false)
Constructor.
tResult ClearEventList()
Clear all buffered queue events.
The class IEventSource provides a generic event provider interface.
virtual T * Get() const =0
Get raw pointer to shared object.
Base object pointer to realize binary compatible reference counting in interface methods.
Object pointer implementation used for reference counting on objects of type IObject.
Definition: object_ptr.h:163
Use this template if you want to implement an ucom::ant::IObject based Interface and/or subclass an e...
Definition: object.h:379
#define A_UTILS_D(__pclassname_)
Helper macro for d-pattern definitions.
Definition: d_ptr.h:270
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Defines the structure for the SampleQueue Insert Compare.
Definition: samplequeue.h:24
bool operator()(const adtf::ucom::iobject_ptr< ISample > &pSampleAdd, const adtf::ucom::iobject_ptr< ISample > &pSample) const
Comparison operator.
Definition: samplequeue.h:31