31 std::recursive_mutex m_oQueueMutex;
32 std::deque<cStreamItem> m_oItems;
65 std::vector<cLastSampleReader*> m_oSampleReaders;
76 m_oSampleReaders.push_back(&oSampleReader);
88 template<
typename ... T>
91 constexpr
size_t nSize =
sizeof...(T);
92 if (m_oSampleReaders.size() > nSize)
94 RETURN_IF_FAILED(m_oSampleReaders[m_oSampleReaders.size() - nSize - 1]->GetLastSample(pSample));
128 tStreamTypeChangeCallback m_pTypeChangeCallback;
132 std::shared_ptr<detail::cExternalSampleReaderQueue> pSampleQueue;
138 std::vector<tQueue> m_oQueues;
178 template<
typename ...T>
181 if (m_oQueues.size() <= 0)
186 constexpr
size_t nSize =
sizeof...(T);
187 if (m_oQueues.size() < nSize)
194 return GetSamples(samples...);
200 template<
typename ... T>
203 constexpr
size_t nSize =
sizeof...(T);
207 return GetSamples(samples...);
235 std::vector<std::shared_ptr<detail::cExternalSampleReaderQueue>> m_oQueues;
236 tStreamTypeChangeCallback m_pTypeChangeCallback;
277 template<
typename ... T>
280 constexpr
size_t nSize =
sizeof...(T);
282 if (m_oQueues.size() < nSize)
287 bool bSampleFound =
false;
288 RETURN_IF_FAILED(GetSampleSetWithCheckAt(tmTime, bSampleFound, samples...));
299 template<
typename ... T>
302 constexpr
size_t nSize =
sizeof...(T);
304 auto& pQueue = m_oQueues[m_oQueues.size() - nSize - 1];
306 bSampleFound |=
IS_OK(pQueue->GetSampleBeforeOrAt(tmTime, pSample, pNewStreamType));
308 if (pNewStreamType && m_pTypeChangeCallback)
310 RETURN_IF_FAILED(m_pTypeChangeCallback(pQueue->GetReader(), pNewStreamType));
313 return GetSampleSetWithCheckAt(tmTime, bSampleFound, samples...);
354 std::recursive_mutex m_oQueueMutex;
355 std::deque<cStreamItem> m_oItems;
366 template<
typename Ret,
typename Class,
typename... Args>
369 using type = std::function<Ret(Args...)>;
374 function_from_lambda(F
const &func)
379 template <
typename ReaderType>
385 auto pReader =
dynamic_cast<ReaderType*
>(&oReader);
390 return fnCallback(*pReader, pStreamType);
394 template <
typename Callable>
396 get_type_change_callback_translator(Callable&& fnCallback)
398 return get_type_change_callback_translator(function_from_lambda(fnCallback));
406 std::vector<ISampleReader*> m_oSampleReaders;
417 m_oSampleReaders.push_back(&oSampleReader);
429 template<
typename ... T>
432 constexpr
size_t nSize =
sizeof...(T);
433 if (m_oSampleReaders.size() > nSize)
435 RETURN_IF_FAILED(m_oSampleReaders[m_oSampleReaders.size() - nSize - 1]->GetLastSample(pSample));
458 template <
typename Callback>
462 m_pTypeChangeCallback = detail::get_type_change_callback_translator(pTypeChangeCallback);
474 template<
typename ...T>
475 tResult GetNextSampleSet(T& ...samples)
477 if (m_oQueues.size() <= 0)
482 constexpr
size_t nSize =
sizeof...(T);
483 if (m_oQueues.size() < nSize)
490 return GetSamples(samples...);
496 template<
typename ... T>
499 constexpr
size_t nSize =
sizeof...(T);
503 return GetSamples(samples...);
512 tStreamTypeChangeCallback m_pTypeChangeCallback;
516 std::shared_ptr<detail::cExternalSampleReaderQueue> pSampleQueue;
522 std::vector<tQueue> m_oQueues;
533 template <
typename Callback>
537 m_pTypeChangeCallback = detail::get_type_change_callback_translator(pTypeChangeCallback);
549 template<
typename ... T>
552 constexpr
size_t nSize =
sizeof...(T);
554 if (m_oQueues.size() < nSize)
559 bool bSampleFound =
false;
560 RETURN_IF_FAILED(GetSampleSetWithCheckAt(tmTime, bSampleFound, samples...));
571 template<
typename ... T>
574 constexpr
size_t nSize =
sizeof...(T);
576 auto& pQueue = m_oQueues[m_oQueues.size() - nSize - 1];
578 bSampleFound |=
IS_OK(pQueue->GetSampleBeforeOrAt(tmTime, pSample, pNewStreamType));
580 if (pNewStreamType && m_pTypeChangeCallback)
582 RETURN_IF_FAILED(m_pTypeChangeCallback(pQueue->GetReader(), pNewStreamType));
585 return GetSampleSetWithCheckAt(tmTime, bSampleFound, samples...);
594 std::vector<std::shared_ptr<detail::cExternalSampleReaderQueue>> m_oQueues;
595 tStreamTypeChangeCallback m_pTypeChangeCallback;
tInt64 tTimeStamp
type definition for a time value.
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
#define RETURN_ERROR_DESC(_code,...)
Same as RETURN_ERROR(_error) using a printf like parameter list for detailed error description.
#define RETURN_IF_FAILED(s)
Return if expression is failed, which requires the calling function's return type to be tResult.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
#define RETURN_ERROR(code)
Return specific error code, which requires the calling function's return type to be tResult.
#define IS_OK(s)
Check if result is OK.
A common result class usable as return value throughout.
Interface to create a sample reader buffer.
The IStreamItem interface is the base type for all object which are passed through a stream.
Sample reader which allows the registration of external queue.
Sample reader which always provides the last successful received sample.
A class that collects the last samples from multiple sample readers.
tResult CollectFrom(cLastSampleReader &oSampleReader)
Adds a sample reader to the list of sample readers that data is read from.
tResult GetLastSamples(adtf::ucom::iobject_ptr< const ISample > &pSample, T &... samples)
Get the last samples from all sample readers if there is no new data in queue, the last sent data is ...
A class that collects the sample sets from multiple sample readers.
tResult GetNextSampleSet(T &...samples)
Get the next sample set from all sample readers at least one reader must have new data based on times...
void ClearQueues()
Clear all internal queues for all connected sample readers.
tResult CollectFrom(cExternalQueueSampleReader &oSampleReader)
Adds a sample reader to the list of sample readers that data is read from.
cSampleSetCollector(tStreamTypeChangeCallback pTypeChangeCallback)
Constructor with type change callback.
Default implementation of an StreamItem as container of the Sample Stream s Queue.
A class that collects the sample sets from multiple sample readers.
tResult GetSampleSetAt(tTimeStamp tmTime, T &... samples)
Get the next sample set from all sample readers.
void ClearQueues()
Clear all internal queues for all connected sample readers.
tResult CollectFrom(cExternalQueueSampleReader &oSampleReader)
Adds a sample reader to the list of sample readers that data is read from.
cTimeBasedSampleSetCollector(tStreamTypeChangeCallback pTypeChangeCallback)
Constructor with type change callback.
tResult Pop(IStreamItem &oStreamItem) override
Returns the next sample from the queue.
void Clear() override
clears the local queue of the reader either only EndStreaming or incoming event ISampleInStream::IQue...
tResult Push(const IStreamItem &oStreamItem, tTimeStamp tmTime) override
Push a new value to the internal sample queue.
Interface for sample reads that read from sample streams via input pins.
tResult GetLastSamples(adtf::ucom::iobject_ptr< const ant::ISample > &pSample, T &... samples)
Get the last samples from all sample readers if there is no new data in queue, the last sent data is ...
tResult CollectFrom(ISampleReader &oSampleReader)
Adds a sample reader to the list of sample readers that data is read from.
tResult Pop(IStreamItem &oStreamItem) override
Returns the next sample from the queue.
void Clear() override
clears the local queue of the reader either only EndStreaming or incoming event ISampleInStream::IQue...
tResult Push(const IStreamItem &oStreamItem, tTimeStamp tmTime) override
Push a new value to the internal sample queue.
virtual tResult Reset(const iobject_ptr< T > &i_oOther)=0
Reset this object_ptr<> with the content of another iobject_ptr<>
Base object pointer to realize binary compatible reference counting in interface methods.
Object pointer implementation used for reference counting on objects of type IObject.
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.