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

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 ISampleStreamAccess::PushRead to register a external queue or to override the adtf::streaming::ant::cSampleReader::ReadNextSample and adtf::streaming::ant::cSampleReader::Push methods. More...

#include <samplereader.h>

Inherits adtf::streaming::ant::sample_streamer< ISampleReader, cInPin >, adtf::streaming::ant::ISampleReaderQueue, and adtf::base::runnable< DEFAULT_ACTIVATION_TYPE, ANT_INTERFACE, flash::IRunnable, CALLABLE >.

Inherited by adtf::streaming::ant::cExternalQueueSampleReader, and adtf::streaming::ant::cLastSampleReader.

Public Member Functions

 cSampleReader ()
 
 cSampleReader (ISampleStreamAccess::tMode eAccessMode)
 
virtual tResult AcceptType (const ucom::ant::iobject_ptr< const IStreamType > &pStreamType)
 Accept or reject a new stream type.
 
tResult BeginStreaming (ISampleStream &oSampleStream) override
 
tResult EndStreaming () override
 
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.
 
void SetStreamErrorCallback (const std::function< tResult(tResult oStreamError)> &fnStreamErrorCallback)
 A callback function to react on stream errors.
 
tResult SetStreamError (const tResult &oError)
 
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)
 
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
 
virtual tResult Pop (IStreamItem &oStreamItem)=0
 Returns the next sample from the queue.
 
- Public Member Functions inherited from adtf::streaming::ant::sample_streamer< ISampleReader, cInPin >
 sample_streamer ()=default
 CTOR.
 
 sample_streamer (const char *strName, const ucom::ant::iobject_ptr< const IStreamType > &pStreamType)
 
virtual ~sample_streamer ()
 DTOR.
 
void SetName (const char *strName)
 
void ResetPin (ucom::ant::object_ptr< cInPin > &pPin)
 
void ResetPin ()
 
tResult GetName (base::ant::IString &&strName) const
 
tResult SetType (const ucom::ant::iobject_ptr< const IStreamType > &pStreamType)
 
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)
 
virtual ~sample_streamer ()
 DTOR.
 
void SetName (const char *strName)
 
void ResetPin (ucom::ant::object_ptr< cInPin > &pPin)
 
void ResetPin ()
 
tResult GetName (base::ant::IString &&strName) const
 
tResult SetType (const ucom::ant::iobject_ptr< const IStreamType > &pStreamType)
 
tResult GetType (ucom::ant::iobject_ptr< const IStreamType > &pStreamType) const override
 
tResult EndStreaming () override
 
- Public Member Functions inherited from adtf::base::runnable< DEFAULT_ACTIVATION_TYPE, ANT_INTERFACE, flash::IRunnable, CALLABLE >
 runnable ()=delete
 CTOR.
 
 runnable (CALLABLE &&fcRunFunc) noexcept
 
 runnable (CALLABLE_WITH_TIMSTAMP &&fcRunFunc) noexcept
 
 runnable (CALLABLE &&fcRunFunc, ant::IRunnable::tActivationType ui32ActivationType) noexcept
 
 ~runnable () override=default
 DTOR.
 
tResult Run (tTimeStamp tmTimeofActivation, ant::IRunnable::tActivationType ui32ActivationType, const void *pvUserData, size_t nUserDataSize) override
 
tResult Run (tNanoSeconds tmTimeofActivation, ant::IRunnable::tActivationType ui32ActivationType, const void *pvUserData, size_t nUserDataSize) override
 
ant::IRunnable::tActivationType GetActivationType () const override
 
 runnable ()=delete
 CTOR.
 
 runnable (CALLABLE &&fcRunFunc) noexcept
 
 runnable (CALLABLE_WITH_TIMSTAMP &&fcRunFunc) noexcept
 
 runnable (CALLABLE &&fcRunFunc, ant::IRunnable::tActivationType ui32ActivationType) noexcept
 
 ~runnable () override=default
 DTOR.
 
tResult Run (tTimeStamp tmTimeofActivation, ant::IRunnable::tActivationType ui32ActivationType, const void *pvUserData, size_t nUserDataSize) override
 
tResult Run (tNanoSeconds tmTimeofActivation, ant::IRunnable::tActivationType ui32ActivationType, const void *pvUserData, size_t nUserDataSize) override
 
ant::IRunnable::tActivationType GetActivationType () const override
 
- Public Member Functions inherited from adtf::ucom::catwo::object< Bases >
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 Member Functions

tResult Push (tTimeStamp tmTimeofActivation)
 internal Push operation to implement pushread mode
 
virtual tResult ReadNextSample (ucom::ant::iobject_ptr< const ISample > &pSample)
 
tResult ProcessStreamItem (const IStreamItem &oStreamItem)
 
tResult HandleStreamError (tResult nError)
 
- Protected Member Functions inherited from adtf::streaming::ant::sample_streamer< ISampleReader, cInPin >
 sample_streamer (const sample_streamer &)=delete
 deleted copy CTOR
 
 sample_streamer (sample_streamer &&)=delete
 deleted move CTOR
 
sample_streameroperator= (const sample_streamer &)=delete
 deleted copy operator
 
sample_streameroperator= (sample_streamer &&)=delete
 deleted move operator
 
 sample_streamer (const sample_streamer &)=delete
 deleted copy CTOR
 
 sample_streamer (sample_streamer &&)=delete
 deleted move CTOR
 
sample_streameroperator= (const sample_streamer &)=delete
 deleted copy operator
 
sample_streameroperator= (sample_streamer &&)=delete
 deleted move operator
 
- Protected Member Functions inherited from adtf::streaming::ant::ISampleReader
 ~ISampleReader ()=default
 not destructable
 
- Protected Member Functions inherited from adtf::streaming::ant::ISampleStreamer
 ~ISampleStreamer ()=default
 not destructable
 
- Protected Member Functions inherited from adtf::ucom::ant::IObject
 ~IObject ()=default
 Protected destructor --> Only the final implementation can be destroyed!
 

Additional Inherited Members

- Public Types inherited from adtf::streaming::ant::sample_streamer< ISampleReader, cInPin >
typedef cInPin pin_type
 
- Protected Attributes inherited from adtf::streaming::ant::sample_streamer< ISampleReader, cInPin >
adtf_util::cString m_strName
 name of the streamer (used i.e. to create the pins name)
 
ucom::object_ptr< const IStreamTypem_pStreamType
 stream type of the streamer
 
ucom::object_ptr< cInPinm_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 IStreamTypem_pStreamType
 stream type of the streamer
 
ucom::object_ptr< cInPinm_poPin
 pin reference reading/writing from
 
- Protected Attributes inherited from adtf::base::runnable< DEFAULT_ACTIVATION_TYPE, ANT_INTERFACE, flash::IRunnable, CALLABLE >
std::decay_t< CALLABLE > m_fcRunFunc
 given function to call on Run
 
std::decay_t< CALLABLE > m_fcRunFunc
 given function to call on Run
 

Detailed Description

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 ISampleStreamAccess::PushRead to register a external queue or to override the adtf::streaming::ant::cSampleReader::ReadNextSample and adtf::streaming::ant::cSampleReader::Push methods.

Constructor & Destructor Documentation

◆ cSampleReader() [1/2]

adtf::streaming::ant::cSampleReader::cSampleReader ( )
inline

Default CTOR.

◆ cSampleReader() [2/2]

adtf::streaming::ant::cSampleReader::cSampleReader ( ISampleStreamAccess::tMode eAccessMode)
inline

Default CTOR which defines the access method.

Parameters
eAccessModethe access method.
Remarks
Only PushRead access methed is implemented at the moment.

Member Function Documentation

◆ AcceptType()

virtual tResult adtf::streaming::ant::cSampleReader::AcceptType ( const ucom::ant::iobject_ptr< const IStreamType > & pStreamType)
virtual

Accept or reject a new stream type.

If the cSampleReader::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 IStreamMetaType::IsCompatible implementation, where the "old" type and its Stream Meta Type decides wether the incoming type is accepted or rejected.

Parameters
[in]pStreamTypeThe incoming Stream Type to accept or reject.
Return values
ERR_INVALID_TYPEthe incoming Stream Type is not valid
ERR_NOERRORthe incoming Stream Type is valid

◆ BeginStreaming()

tResult adtf::streaming::ant::cSampleReader::BeginStreaming ( ISampleStream & pStream)
inlineoverridevirtual

BeginStreaming will open the given Sample Stream for Reading while a connection is establishing.

Parameters
pStream[in] Sample Stream to open
Returns
Result Code depends on the implementation

Implements adtf::streaming::ant::ISampleReader.

◆ Clear()

virtual void adtf::streaming::ant::ISampleReaderQueue::Clear ( )
virtual

clears the local queue of the reader either only EndStreaming or incoming event ISampleInStream::IQueueItem::RE_Flush

Implements adtf::streaming::ant::ISampleReaderQueue.

◆ EndStreaming()

tResult adtf::streaming::ant::cSampleReader::EndStreaming ( )
inlineoverridevirtual

Sample Stream disconnected. Streaming ends.

Returns
Standard Result Code. Depends on implmentation.

Implements adtf::streaming::ant::ISampleStreamer.

◆ GetNextSample()

virtual tResult adtf::streaming::ant::cSampleReader::GetNextSample ( ucom::ant::iobject_ptr< const ISample > & pSample)
inlinevirtual

Gets the next Sample within internal queue which not has been read. param[out] pSample Sample found

Returns
Standard Result Code
Return values
ERR_EMPTYNo Sample found.

◆ Pop()

virtual tResult adtf::streaming::ant::ISampleReaderQueue::Pop ( IStreamItem & oStreamItem)
virtual

Returns the next sample from the queue.

Parameters
[out]oStreamItemstream item reference to copy the references to

Implements adtf::streaming::ant::ISampleReaderQueue.

◆ ProcessStreamItem()

tResult adtf::streaming::ant::cSampleReader::ProcessStreamItem ( const IStreamItem & oStreamItem)
inlineprotected

This will process the stream items.

This method will cal the user hook callbacks for accepting type (cSampleReader::SetAcceptTypeCallback)

Parameters
oStreamItemRecently read stream item.
Returns
internal or user error code.
Return values
ERR_INVALID_TYPEreceived stream type was not accepted.
ERR_NOT_CONNECTEDNo sample stream is connected and the cSampleReader::BeginStreaming is not called yet.

◆ Push()

virtual tResult adtf::streaming::ant::ISampleReaderQueue::Push ( const IStreamItem & oStreamItem,
tTimeStamp tmTime )
virtual

Push a new value to the internal sample queue.

Parameters
[in]oStreamItemThe sample to store
[in]tmTimeTime of storage

Implements adtf::streaming::ant::ISampleReaderQueue.

◆ ReadNextSample()

virtual tResult adtf::streaming::ant::cSampleReader::ReadNextSample ( ucom::ant::iobject_ptr< const ISample > & pSample)
inlineprotectedvirtual

This will read the stream items until a sample is reached and return it. If another stream item type is reached than sample, cSampleReader::ProcessStreamItem will handle it.

Parameters
pSamplesample reference set if valid.
Returns
error code
Return values
ERR_EMPTYstream is empty
ERR_INVALID_TYPEreceived stream type was not accepted.
ERR_NOT_CONNECTEDNo sample stream is connected and the cSampleReader::BeginStreaming is not called yet.

Reimplemented in adtf::streaming::ant::cLastSampleReader.

◆ SetAcceptTypeCallback()

void adtf::streaming::ant::cSampleReader::SetAcceptTypeCallback ( const std::function< tResult(const ucom::iobject_ptr< const IStreamType > &pStreamType)> & fnAcceptTypeCallback)
inline

Sets a callback function which is called while a Stream Type is received.

Parameters
[in]fnAcceptTypeCallbackThe 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.

◆ SetStreamError()

tResult adtf::streaming::ant::cSampleReader::SetStreamError ( const tResult & oError)
inline

Forward an error to the corresponding stream.

Parameters
oError[in] The error passed to the SampleStream.
Returns
Standard Result Code.

◆ SetStreamErrorCallback()

void adtf::streaming::ant::cSampleReader::SetStreamErrorCallback ( const std::function< tResult(tResult oStreamError)> & fnStreamErrorCallback)
inline

A callback function to react on stream errors.

Parameters
[in]fnStreamErrorCallbackThe callback function which will be called on stream errors

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