ADTF  3.14.3
cSampleReader

The default Sample Reader will read the incomung Stream of a IInPin. More...

Inheritance diagram for cSampleReader:
[legend]

Public Member Functions

 cSampleReader ()
 Default CTOR.
 
 cSampleReader (ISampleStreamAccess::tMode eAccessMode)
 Default CTOR which defines the access method. More...
 
virtual tResult AcceptType (const ucom::ant::iobject_ptr< const IStreamType > &pStreamType)
 Accept or reject a new stream type - see also AcceptType and IsCompatible implementations. More...
 
tResult BeginStreaming (ISampleStream &oSampleStream) override
 BeginStreaming will open the given Sample Stream for Reading while a connection is establishing. More...
 
tResult EndStreaming () override
 Sample Stream disconnected. More...
 
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. More...
 
void SetStreamErrorCallback (const std::function< tResult(tResult oStreamError)> &fnStreamErrorCallback)
 A callback function to react on stream errors. More...
 
tResult SetStreamError (const tResult &oError)
 Forward an error to the corresponding stream. More...
 
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. More...
 
void Reset () override
 
virtual tResult Push (const IStreamItem &oStreamItem, tTimeStamp tmTime)=0
 Push a new value to the internal sample queue. More...
 
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. More...
 
- Public Member Functions inherited from sample_streamer< ISampleReader, cInPin >
 sample_streamer ()=default
 CTOR.
 
 sample_streamer (const char *strName, const ucom::ant::iobject_ptr< const IStreamType > &pStreamType)
 CTOR initializer. More...
 
virtual ~sample_streamer ()
 DTOR.
 
void SetName (const char *strName)
 Sets the name of the streamer. More...
 
void ResetPin (ucom::ant::object_ptr< cInPin > &pPin)
 Resets the pin reference This is only internaly used. More...
 
void ResetPin ()
 Resets the pin reference to nullptr. More...
 
tResult GetName (base::ant::IString &&strName) const
 Gets the name of the streamer. More...
 
tResult SetType (const ucom::ant::iobject_ptr< const IStreamType > &pStreamType)
 Sets the StreamType of the streamer. More...
 
tResult GetType (ucom::ant::iobject_ptr< const IStreamType > &pStreamType) const override
 
tResult EndStreaming () override
 
- Public Member Functions inherited from ISampleReaderQueue
virtual tResult Push (const IStreamItem &oStreamItem, tTimeStamp tmTime)=0
 Push a new value to the internal sample queue. More...
 
virtual tResult Pop (IStreamItem &oStreamItem)=0
 Returns the next sample from the queue. More...
 
- Public Member Functions inherited from runnable< base::ant::IRunnable::RUN_PUSH, ISampleStream::IPushReadEventSink >
 runnable ()
 CTOR.
 
 runnable (IRunnable::tRunFunction fcRunOnceFunc)
 Main CTOR with callable function. More...
 
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. More...
 
virtual IRunnable::tActivationType GetActivationType () const
 Returns the type of activation implemented. More...
 
- Public Member Functions inherited from object< Bases >
tResult GetInterface (const char *i_strIID, void *&o_pInterface) override
 Query interfaces on an object. More...
 
tResult GetInterface (const char *i_strIID, const void *&o_pInterface) const override
 Provides const correct interface querying. More...
 
void Destroy () const override
 Destruct and deallocate instantiations of type IObject. More...
 
- Public Member Functions inherited from IObject
 ADTF_IID (IObject, "object.ant.ucom.adtf.iid")
 Marks the IObject to be castable with the ucom_cast() More...
 

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. More...
 
tResult ProcessStreamItem (const IStreamItem &oStreamItem)
 This will process the stream items. More...
 
tResult HandleStreamError (tResult nError)
 
- Protected Member Functions inherited from 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
 
- Protected Member Functions inherited from ISampleReader
 ~ISampleReader ()=default
 not destructable
 
- Protected Member Functions inherited from ISampleStreamer
 ~ISampleStreamer ()=default
 not destructable
 
- Protected Member Functions inherited from IObject
 ~IObject ()=default
 Protected destructor --> Use implemented Destroy() instead of delete!
 

Private Types

typedef sample_streamer< ISampleReader, cInPinbase_type
 base type of cSampleReader
 
typedef base::ant::runnable< base::ant::IRunnable::RUN_PUSH, ISampleStream::IPushReadEventSinkrunnable_type
 internal base type.
 

Private Attributes

ucom::object_ptr< ISampleInStreamm_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 IStreamTypem_pLastReadStreamType
 Last accepted incoming type.
 
ISampleStreamAccess::tMode m_eAccessMode
 current access method
 

Additional Inherited Members

- Public Types inherited from sample_streamer< ISampleReader, cInPin >
typedef cInPin pin_type
 
- Protected Attributes inherited from 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
 
- Protected Attributes inherited from runnable< base::ant::IRunnable::RUN_PUSH, ISampleStream::IPushReadEventSink >
IRunnable::tRunFunction m_fcRunOnceFunc
 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::Push, cSampleReader::ReadNextSample and cSampleReader::Push methods (for more detail see sample_reader)

Definition at line 171 of file samplereader.h.

Constructor & Destructor Documentation

◆ 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.

Definition at line 220 of file samplereader.h.

Member Function Documentation

◆ AcceptType()

virtual tResult AcceptType ( const ucom::ant::iobject_ptr< const IStreamType > &  pStreamType)
inlinevirtual

Accept or reject a new stream type - see also AcceptType and IsCompatible implementations.

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
See also
AcceptType and IsCompatible implementations

Definition at line 241 of file samplereader.h.

References iobject_ptr_base< T >::Get(), cSampleReader::m_fnAcceptTypeCallback, cSampleReader::m_pLastReadStreamType, sample_streamer< ISampleReader, cInPin >::m_pStreamType, and RETURN_IF_FAILED.

Referenced by cSampleReader::ProcessStreamItem().

◆ BeginStreaming()

tResult 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 ISampleReader.

Definition at line 262 of file samplereader.h.

References cSampleReader::EndStreaming(), cSampleReader::m_eAccessMode, cSampleReader::m_oReadLock, cSampleReader::m_pInStream, sample_streamer< ISampleReader, cInPin >::m_pStreamType, sample_streamer< ISampleReader, cInPin >::m_strName, ISampleStream::Open(), and RETURN_IF_FAILED.

◆ EndStreaming()

tResult EndStreaming ( )
inlineoverridevirtual

Sample Stream disconnected.

Streaming ends.

Returns
Standard Result Code. Depends on implmentation.

Implements ISampleStreamer.

Definition at line 288 of file samplereader.h.

References cSampleReader::Clear(), cSampleReader::m_oReadLock, and cSampleReader::m_pInStream.

Referenced by cSampleReader::BeginStreaming().

◆ GetNextSample()

virtual tResult 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.

Definition at line 364 of file samplereader.h.

References cSampleReader::ReadNextSample().

Referenced by adtf::streaming::ant::operator>>().

◆ Pop()

virtual tResult Pop

Returns the next sample from the queue.

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

Referenced by cSampleReader::ReadNextSample().

◆ ProcessStreamItem()

tResult 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 and Stream Meta Type was not accepted.
ERR_NOT_CONNECTEDNo Sample Stream is connected and the cSampleReader::BeginStreaming is not called yet.

Definition at line 452 of file samplereader.h.

References cSampleReader::AcceptType(), ADTF_BASE_COMPOSED_RESULT, IStreamItem::GetStreamType(), IStreamItem::GetType(), cSampleReader::m_bValidType, RETURN_IF_FAILED, and IStreamItem::StreamType.

Referenced by cSampleReader::ReadNextSample().

◆ Push()

virtual tResult Push

Push a new value to the internal sample queue.

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

Referenced by cSampleReader::Push().

◆ ReadNextSample()

virtual tResult 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 and Stream Meta Type was not accepted.
ERR_NOT_CONNECTEDNo Sample Stream is connected and the cSampleReader::BeginStreaming is not called yet.

Reimplemented in cLastSampleReader.

Definition at line 412 of file samplereader.h.

References ISampleStreamAccess::AsyncQueue, cStreamItem::GetSample(), cStreamItem::GetType(), cSampleReader::m_pInStream, cSampleReader::Pop(), cSampleReader::ProcessStreamItem(), RETURN_IF_FAILED, and IStreamItem::Sample.

Referenced by cSampleReader::GetNextSample(), and cLastSampleReader::ReadNextSample().

◆ SetAcceptTypeCallback()

void 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 - see also AcceptType and IsCompatible implementations.

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.

Definition at line 306 of file samplereader.h.

References cSampleReader::m_fnAcceptTypeCallback.

◆ SetStreamError()

tResult 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.

Definition at line 323 of file samplereader.h.

References cSampleReader::m_oReadLock, and cSampleReader::m_pInStream.

◆ SetStreamErrorCallback()

void 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

Definition at line 316 of file samplereader.h.

References cSampleReader::m_fnStreamErrorCallback.


Copyright © Audi Electronics Venture GmbH. All rights reserved. (Generated on Thu Jun 9 2022 by doxygen 1.9.1)