The default Sample Reader will read the incomung Stream of a IInPin. More...
#include <samplereader.h>
Public Member Functions | |
cSampleReader () | |
Default CTOR. | |
cSampleReader (ISampleStreamAccess::tMode eAccessMode) | |
Default CTOR which defines the access method. | |
virtual tResult | AcceptType (const ucom::ant::iobject_ptr< const IStreamType > &pStreamType) |
Accept or reject a new stream type - see also AcceptType and IsCompatible implementations. | |
tResult | BeginStreaming (ISampleStream &oSampleStream) override |
BeginStreaming will open the given Sample Stream for Reading while a connection is establishing. | |
tResult | EndStreaming () override |
Sample Stream disconnected. | |
void | SetAcceptTypeCallback (const std::function< tResult(const ucom::iobject_ptr< const IStreamType > &pStreamType)> &fnAcceptTypeCallback) |
Sets a callback function which is called while a Stream Type is received - see also AcceptType and IsCompatible implementations. | |
void | SetStreamErrorCallback (const std::function< tResult(tResult oStreamError)> &fnStreamErrorCallback) |
A callback function to react on stream errors. | |
tResult | SetStreamError (const tResult &oError) |
Forward an error to the corresponding stream. | |
void | GetSampleInStream (ucom::ant::iobject_ptr< ISampleInStream > &pSampleInStream) |
Returns the connected ISampleInStream. | |
void | GetLastType (ucom::ant::iobject_ptr< const IStreamType > &pType) |
Returns the connected ISampleInStream. | |
virtual tResult | GetNextSample (ucom::ant::iobject_ptr< const ISample > &pSample) |
Gets the next Sample within internal queue which not has been read. | |
void | Reset () override |
virtual tResult | Push (const IStreamItem &oStreamItem, tTimeStamp tmTime)=0 |
Push a new value to the internal sample queue. | |
virtual void | Clear ()=0 |
clears the local queue of the reader either only EndStreaming or incoming event ISampleInStream::IQueueItem::RE_Flush | |
virtual tResult | Pop (IStreamItem &oStreamItem)=0 |
Returns the next sample from the queue. | |
![]() | |
sample_streamer ()=default | |
CTOR. | |
sample_streamer (const char *strName, const ucom::ant::iobject_ptr< const IStreamType > &pStreamType) | |
CTOR initializer. | |
virtual | ~sample_streamer () |
DTOR. | |
void | SetName (const char *strName) |
Sets the name of the streamer. | |
void | ResetPin (ucom::ant::object_ptr< cInPin > &pPin) |
Resets the pin reference This is only internaly used. | |
void | ResetPin () |
Resets the pin reference to nullptr. | |
tResult | GetName (base::ant::IString &&strName) const |
Gets the name of the streamer. | |
tResult | SetType (const ucom::ant::iobject_ptr< const IStreamType > &pStreamType) |
Sets the StreamType of the streamer. | |
tResult | GetType (ucom::ant::iobject_ptr< const IStreamType > &pStreamType) const override |
tResult | EndStreaming () override |
sample_streamer ()=default | |
CTOR. | |
sample_streamer (const char *strName, const ucom::ant::iobject_ptr< const IStreamType > &pStreamType) | |
CTOR initializer. | |
virtual | ~sample_streamer () |
DTOR. | |
void | SetName (const char *strName) |
Sets the name of the streamer. | |
void | ResetPin (ucom::ant::object_ptr< cInPin > &pPin) |
Resets the pin reference This is only internaly used. | |
void | ResetPin () |
Resets the pin reference to nullptr. | |
tResult | GetName (base::ant::IString &&strName) const |
Gets the name of the streamer. | |
tResult | SetType (const ucom::ant::iobject_ptr< const IStreamType > &pStreamType) |
Sets the StreamType of the streamer. | |
tResult | GetType (ucom::ant::iobject_ptr< const IStreamType > &pStreamType) const override |
tResult | EndStreaming () override |
![]() | |
runnable () | |
CTOR. | |
runnable (IRunnable::tRunFunction fcRunOnceFunc) | |
Main CTOR with callable function. | |
virtual | ~runnable ()=default |
DTOR. | |
tResult | Run (tTimeStamp tmTimeofActivation, IRunnable::tActivationType ui32ActivationType, const void *, size_t) override |
IRunnable::Run implementation which will call m_fcRunOnceFunc if ui32ActivationType is TYPE_OF_ACTIVATION . | |
virtual IRunnable::tActivationType | GetActivationType () const |
Returns the type of activation implemented. | |
runnable () | |
CTOR. | |
runnable (IRunnable::tRunFunction fcRunOnceFunc) | |
Main CTOR with callable function. | |
virtual | ~runnable ()=default |
DTOR. | |
tResult | Run (tTimeStamp tmTimeofActivation, IRunnable::tActivationType ui32ActivationType, const void *, size_t) override |
IRunnable::Run implementation which will call m_fcRunOnceFunc if ui32ActivationType is TYPE_OF_ACTIVATION . | |
virtual IRunnable::tActivationType | GetActivationType () const |
Returns the type of activation implemented. | |
![]() | |
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. | |
![]() | |
ADTF_IID (IObject, "object.ant.ucom.adtf.iid") | |
Marks the IObject to be castable with the ucom_cast() | |
Protected Member Functions | |
tResult | Push (tTimeStamp tmTimeofActivation) |
internal Push operation to implement pushread mode | |
virtual tResult | ReadNextSample (ucom::ant::iobject_ptr< const ISample > &pSample) |
This will read the stream items until a sample is reached and return it. | |
tResult | ProcessStreamItem (const IStreamItem &oStreamItem) |
This will process the stream items. | |
tResult | HandleStreamError (tResult nError) |
![]() | |
sample_streamer (const sample_streamer &)=delete | |
deleted copy CTOR | |
sample_streamer (sample_streamer &&)=delete | |
deleted move CTOR | |
sample_streamer & | operator= (const sample_streamer &)=delete |
deleted copy operator | |
sample_streamer & | operator= (sample_streamer &&)=delete |
deleted move operator | |
sample_streamer (const sample_streamer &)=delete | |
deleted copy CTOR | |
sample_streamer (sample_streamer &&)=delete | |
deleted move CTOR | |
sample_streamer & | operator= (const sample_streamer &)=delete |
deleted copy operator | |
sample_streamer & | operator= (sample_streamer &&)=delete |
deleted move operator | |
![]() | |
~ISampleReader ()=default | |
not destructable | |
![]() | |
~ISampleStreamer ()=default | |
not destructable | |
![]() | |
~IObject ()=default | |
Protected destructor --> Only the final implementation can be destroyed! | |
Private Types | |
typedef sample_streamer< ISampleReader, cInPin > | base_type |
base type of cSampleReader | |
typedef base::ant::runnable< base::ant::IRunnable::RUN_PUSH, ISampleStream::IPushReadEventSink > | runnable_type |
internal base type. | |
Private Attributes | |
ucom::object_ptr< ISampleInStream > | m_pInStream |
Reader where to read. | |
std::mutex | m_oReadLock |
Read synchronization. | |
std::function< tResult(const ucom::iobject_ptr< const IStreamType > &pStreamType)> | m_fnAcceptTypeCallback |
Callback to reject type changes. | |
std::function< tResult(tResult oStreamError)> | m_fnStreamErrorCallback |
Callback to react on stream errors. | |
bool | m_bValidType = true |
state wether the current type is a valid type or not this will be set to false in AcceptType fails. | |
ucom::object_ptr< const IStreamType > | m_pLastReadStreamType |
Last accepted incoming type. | |
ISampleStreamAccess::tMode | m_eAccessMode |
current access method | |
Additional Inherited Members | |
![]() | |
typedef cInPin | pin_type |
![]() | |
adtf_util::cString | m_strName |
name of the streamer (used i.e. to create the pins name) | |
ucom::object_ptr< const IStreamType > | m_pStreamType |
stream type of the streamer | |
ucom::object_ptr< cInPin > | m_poPin |
pin reference reading/writing from | |
adtf_util::cString | m_strName |
name of the streamer (used i.e. to create the pins name) | |
ucom::object_ptr< const IStreamType > | m_pStreamType |
stream type of the streamer | |
ucom::object_ptr< cInPin > | m_poPin |
pin reference reading/writing from | |
![]() | |
IRunnable::tRunFunction | m_fcRunOnceFunc |
given function to call on Run | |
IRunnable::tRunFunction | m_fcRunOnceFunc |
given function to call on Run | |
The default Sample Reader will read the incomung Stream of a IInPin.
This sample reader has no internal queue! Make sure if you use this sample reader with PushRead to register a external queue or to override the Push, ReadNextSample and Push methods (for more detail see sample_reader)
Definition at line 171 of file samplereader.h.
|
private |
base type of cSampleReader
Definition at line 181 of file samplereader.h.
|
private |
internal base type.
Definition at line 190 of file samplereader.h.
|
inline |
Default CTOR.
Definition at line 209 of file samplereader.h.
References ADTF_RUN_FUNCTION, m_eAccessMode, and Push().
|
inline |
Default CTOR which defines the access method.
eAccessMode | the access method. |
Definition at line 220 of file samplereader.h.
References ADTF_RUN_FUNCTION, m_eAccessMode, and Push().
|
virtual |
Accept or reject a new stream type - see also AcceptType and IsCompatible implementations.
If the SetAcceptTypeCallback method was used to set a accept sample callback method the internal meta type comparison will be replaced. The internal meta type comparison uses the IsCompatible implementation, where the "old" type and its Stream Meta Type decides wether the incoming type is accepted or rejected.
[in] | pStreamType | The incoming Stream Type to accept or reject. |
ERR_INVALID_TYPE | the incoming Stream Type is not valid |
ERR_NOERROR | the incoming Stream Type is valid |
Referenced by ProcessStreamItem().
|
inlineoverridevirtual |
BeginStreaming will open the given Sample Stream for Reading while a connection is establishing.
pStream | [in] Sample Stream to open |
Implements ISampleReader.
Definition at line 244 of file samplereader.h.
References EndStreaming(), m_eAccessMode, m_oReadLock, m_pInStream, sample_streamer< ISampleReader, cInPin >::m_pStreamType, sample_streamer< ISampleReader, cInPin >::m_strName, ISampleStream::Open(), ISampleStreamAccess::PushRead, RETURN_ERROR_DESC, RETURN_IF_FAILED, and RETURN_NOERROR.
|
virtual |
clears the local queue of the reader either only EndStreaming or incoming event ISampleInStream::IQueueItem::RE_Flush
Implements ISampleReaderQueue.
Referenced by EndStreaming().
|
inlineoverridevirtual |
Sample Stream disconnected.
Streaming ends.
Implements ISampleStreamer.
Definition at line 270 of file samplereader.h.
References Clear(), m_oReadLock, m_pInStream, and RETURN_NOERROR.
Referenced by BeginStreaming().
|
inline |
Returns the connected ISampleInStream.
Definition at line 327 of file samplereader.h.
References m_pLastReadStreamType, sample_streamer< ISampleReader, cInPin >::m_pStreamType, and iobject_ptr_base< T >::Reset().
Referenced by adtf::streaming::ant::operator>>().
|
inlinevirtual |
Gets the next Sample within internal queue which not has been read.
param[out] pSample Sample found
ERR_EMPTY | No Sample found. |
Definition at line 346 of file samplereader.h.
References ReadNextSample().
Referenced by adtf::streaming::ant::operator>>(), adtf::streaming::ant::operator>>(), and adtf::streaming::ant::operator>>().
|
inline |
Returns the connected ISampleInStream.
Definition at line 319 of file samplereader.h.
References m_pInStream, and iobject_ptr_base< T >::Reset().
Definition at line 480 of file samplereader.h.
|
virtual |
Returns the next sample from the queue.
[out] | oStreamItem | stream item reference to copy the references to |
Implements ISampleReaderQueue.
Referenced by ReadNextSample().
|
inlineprotected |
This will process the stream items.
This method will cal the user hook callbacks for accepting type (SetAcceptTypeCallback)
oStreamItem | Recently read stream item. |
ERR_INVALID_TYPE | received Stream Type and Stream Meta Type was not accepted. |
ERR_NOT_CONNECTED | No Sample Stream is connected and the BeginStreaming is not called yet. |
Definition at line 434 of file samplereader.h.
References AcceptType(), ADTF_BASE_COMPOSED_RESULT, IStreamItem::GetStreamType(), IStreamItem::GetType(), IS_FAILED, m_bValidType, RETURN_ERROR, RETURN_IF_FAILED, RETURN_NOERROR, and IStreamItem::StreamType.
Referenced by ReadNextSample().
|
virtual |
Push a new value to the internal sample queue.
[in] | oStreamItem | The sample to store |
[in] | tmTime | Time of storage |
Implements ISampleReaderQueue.
|
inlineprotected |
internal Push operation to implement pushread mode
Definition at line 353 of file samplereader.h.
References IS_FAILED, LOG_DUMP, m_oReadLock, m_pInStream, Push(), RETURN_ERROR, RETURN_IF_FAILED, and RETURN_NOERROR.
Referenced by cSampleReader(), cSampleReader(), and Push().
|
inlineprotectedvirtual |
This will read the stream items until a sample is reached and return it.
If another stream item type is reached than sample, ProcessStreamItem will handle it.
pSample | sample reference set if valid. |
ERR_EMPTY | stream is empty |
ERR_INVALID_TYPE | received Stream Type and Stream Meta Type was not accepted. |
ERR_NOT_CONNECTED | No Sample Stream is connected and the BeginStreaming is not called yet. |
Reimplemented in cLastSampleReader.
Definition at line 394 of file samplereader.h.
References ISampleStreamAccess::AsyncQueue, cStreamItem::GetSample(), cStreamItem::GetType(), IS_OK, m_pInStream, Pop(), ProcessStreamItem(), RETURN_IF_FAILED, and IStreamItem::Sample.
Referenced by GetNextSample(), and cLastSampleReader::ReadNextSample().
|
inlineoverride |
Definition at line 468 of file samplereader.h.
|
inline |
Sets a callback function which is called while a Stream Type is received - see also AcceptType and IsCompatible implementations.
[in] | fnAcceptTypeCallback | The callback function is called while AcceptType is executed. It must return ERR_NOERROR to accept the type or any error to reject the new type. |
Definition at line 288 of file samplereader.h.
References m_fnAcceptTypeCallback.
Forward an error to the corresponding stream.
oError | [in] The error passed to the SampleStream. |
Definition at line 305 of file samplereader.h.
References m_oReadLock, m_pInStream, and RETURN_ERROR.
|
inline |
A callback function to react on stream errors.
[in] | fnStreamErrorCallback | The callback function which will be called on stream errors |
Definition at line 298 of file samplereader.h.
References m_fnStreamErrorCallback.
|
private |
state wether the current type is a valid type or not this will be set to false in AcceptType fails.
Definition at line 196 of file samplereader.h.
Referenced by ProcessStreamItem().
|
private |
current access method
Definition at line 203 of file samplereader.h.
Referenced by cSampleReader(), cSampleReader(), and BeginStreaming().
|
private |
Callback to reject type changes.
Definition at line 183 of file samplereader.h.
Referenced by SetAcceptTypeCallback().
Callback to react on stream errors.
Definition at line 185 of file samplereader.h.
Referenced by SetStreamErrorCallback().
|
private |
Read synchronization.
Definition at line 179 of file samplereader.h.
Referenced by BeginStreaming(), EndStreaming(), Push(), and SetStreamError().
|
private |
Reader where to read.
Definition at line 177 of file samplereader.h.
Referenced by BeginStreaming(), EndStreaming(), GetSampleInStream(), Push(), ReadNextSample(), and SetStreamError().
|
private |
Last accepted incoming type.
Definition at line 200 of file samplereader.h.
Referenced by GetLastType().