ADTF
Loading...
Searching...
No Matches
adtf::streaming::requestable_writer< BaseWriter > Class Template Reference

#include <requestable_writer.h>

Inherits adtf::streaming::hollow::writer_with_request_broker< adtf::streaming::cSampleWriter >.

Public Member Functions

 requestable_writer ()
 
void SetCallbacks (std::function< void(uint32_t, const base::IProperties *)> fnEnable, std::function< void(uint32_t)> fnDisable)
 
tResult SetType (const ucom::ant::iobject_ptr< const ant::IStreamType > &pType) override
 
tResult ChangeType (const ucom::ant::iobject_ptr< const ant::IStreamType > &pType) override
 
tResult ChangeType (const ucom::ant::iobject_ptr< const ant::IStreamType > &pType, bool bDisableCurrentRequests, bool bCallDisableCallback)
 
tResult ChangeType (const ucom::ant::iobject_ptr< const ant::IStreamType > &pType, bool bDisableCurrentRequests, bool bCallDisableCallback, bool bSync)
 
tResult EndStreaming () override
 
- Public Member Functions inherited from adtf::streaming::hollow::writer_with_request_broker< adtf::streaming::cSampleWriter >
void SetBroker (const ucom::ant::iobject_ptr< IStreamingRequests > &pBroker)
 
tResult BeginStreaming (streaming::ant::ISampleStream &oSampleStream) override
 
tResult EndStreaming () override
 
- Public Member Functions inherited from adtf::streaming::flash::cSampleWriter
void SetName (const char *strName) override
 
tResult GetName (base::ant::IString &&strName) override
 
tResult GetType (ucom::ant::iobject_ptr< const ant::IStreamType > &pStreamType) const override
 
tResult SetStreamerPin (const ucom::ant::iobject_ptr< IStreamerPin > &pStreamerPin) override
 
tResult GetStreamerPin (ucom::ant::iobject_ptr< IStreamerPin > &pStreamerPin) const
 
tResult Write (const ucom::ant::iobject_ptr< const ant::ISample > &pSample) override
 
virtual tResult Transmit (const ucom::ant::iobject_ptr< const ant::ISample > &pSample)
 
tResult Flush () override
 
tResult SetStreamError (tResult oError) override
 
tResult ManualTrigger (base::flash::tNanoSeconds tmActivationTime=base::flash::tNanoSeconds{-1}) override
 

Detailed Description

template<typename BaseWriter = adtf::streaming::cSampleWriter>
class adtf::streaming::requestable_writer< BaseWriter >

Writer that registers a request broker (cRequestBroker) at the connected sample stream.

Example Usage

#include <set>
#include <mutex>
class cMyFilter: public adtf::filter::cFilter
{
public:
ADTF_CLASS_ID_NAME(cMyFilter, "my_filter.filter.example.cid", "My Filter");
cMyFilter()
{
CreateRunner("generate_samples");
m_pWriter = CreateOutputPin<adtf::streaming::requestable_writer<>>("output", oSubStreams);
m_pWriter->SetCallbacks([this](uint32_t nSubStreamId, const adtf::base::IProperties*)
{
if (nSubStreamId > 2)
{
THROW_ERROR_DESC(ERR_INVALID_ARG, "No substream with id %" PRIu32 " available", nSubStreamId);
}
std::lock_guard<std::mutex> oGuard(m_oSubStreamsLock);
m_oEnabledSubStreams.insert(nSubStreamId);
},
[this](uint32_t nSubStreamId)
{
std::lock_guard<std::mutex> oGuard(m_oSubStreamsLock);
m_oEnabledSubStreams.erase(nSubStreamId);
});
}
tResult Process(adtf::base::tNanoSeconds tmTrigger, adtf::streaming::IRunner* /*pRunner*/) override
{
++m_nTriggerCounter;
std::lock_guard<std::mutex> oGuard(m_oSubStreamsLock);
for (const auto& nSubStreamId: m_oEnabledSubStreams)
{
adtf::streaming::output_sample_data<uint32_t> oNewData(tmTrigger, m_nTriggerCounter, nSubStreamId);
m_pWriter->Write(oNewData.Release());
}
}
private:
adtf::streaming::requestable_writer<>* m_pWriter = nullptr;
std::mutex m_oSubStreamsLock;
std::set<uint32_t> m_oEnabledSubStreams;
uint32_t m_nTriggerCounter = 0;
};
#define THROW_ERROR_DESC(_code,...)
throws a tResult exception
Definition result.h:85
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:736
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
Definition result.h:29
#define ADTF_CLASS_ID_NAME(_class, _strcid, _strclabel)
Definition class_id.h:33
Definition property_intf.h:213
Definition filter.h:289
virtual tResult Process(base::flash::tNanoSeconds tmTrigger, streaming::ant::IRunner *pRunner)
streaming::ant::IRunner * CreateRunner(const char *strName, const cTriggerHint &oTriggerHint=cNoTriggerHint(), bool bForwardTriggerViaOutputPins=true)
Definition stream_type_helper.h:154
void SetSubStream(const char *strName, uint32_t nSubStreamId, const flash::cStreamTypeHelper &oType)
Generator template to create an instance of a ant::IStreamType class for penguin::stream_meta_type_pl...
Definition streammetatypeplain.h:315

Constructor & Destructor Documentation

◆ requestable_writer()

template<typename BaseWriter = adtf::streaming::cSampleWriter>
adtf::streaming::hollow::requestable_writer< BaseWriter >::requestable_writer ( )
inline

Default constructor.

Member Function Documentation

◆ ChangeType() [1/2]

template<typename BaseWriter = adtf::streaming::cSampleWriter>
tResult adtf::streaming::hollow::requestable_writer< BaseWriter >::ChangeType ( const ucom::ant::iobject_ptr< const ant::IStreamType > & pType)
inlineoverridevirtual

Communicates a type change for all following samples.

Parameters
[in]pTypeThe new stream type
Returns
Standard result. Errors will be reported via the associated sample stream.

Reimplemented from adtf::streaming::flash::cSampleWriter.

◆ ChangeType() [2/2]

template<typename BaseWriter = adtf::streaming::cSampleWriter>
tResult adtf::streaming::hollow::requestable_writer< BaseWriter >::ChangeType ( const ucom::ant::iobject_ptr< const ant::IStreamType > & pType,
bool bDisableCurrentRequests,
bool bCallDisableCallback )
inline

Writes a new Stream Type to the Sample Stream.

Parameters
[in]pTypeThe new Stream Type.
[in]bDisableCurrentRequestsIf true, current requests will be disabled.
[in]bCallDisableCallbackIf bDisableCurrentRequests was true, whether or not to call the disable callback for all ongoing requests.
Returns
Standard result.

◆ EndStreaming()

template<typename BaseWriter = adtf::streaming::cSampleWriter>
tResult adtf::streaming::hollow::requestable_writer< BaseWriter >::EndStreaming ( )
inlineoverridevirtual

End streaming

Returns
Standard result.

Reimplemented from adtf::streaming::flash::cSampleWriter.

◆ SetCallbacks()

template<typename BaseWriter = adtf::streaming::cSampleWriter>
void adtf::streaming::hollow::requestable_writer< BaseWriter >::SetCallbacks ( std::function< void(uint32_t, const base::IProperties *)> fnEnable,
std::function< void(uint32_t)> fnDisable )
inline

Sets the callbacks for activating and deactivating substreams.

Example Usage

#include <set>
#include <mutex>
class cMyFilter: public adtf::filter::cFilter
{
public:
ADTF_CLASS_ID_NAME(cMyFilter, "my_filter.filter.example.cid", "My Filter");
cMyFilter()
{
CreateRunner("generate_samples");
m_pWriter = CreateOutputPin<adtf::streaming::requestable_writer<>>("output", oSubStreams);
m_pWriter->SetCallbacks([this](uint32_t nSubStreamId, const adtf::base::IProperties*)
{
if (nSubStreamId > 2)
{
THROW_ERROR_DESC(ERR_INVALID_ARG, "No substream with id %" PRIu32 " available", nSubStreamId);
}
std::lock_guard<std::mutex> oGuard(m_oSubStreamsLock);
m_oEnabledSubStreams.insert(nSubStreamId);
},
[this](uint32_t nSubStreamId)
{
std::lock_guard<std::mutex> oGuard(m_oSubStreamsLock);
m_oEnabledSubStreams.erase(nSubStreamId);
});
}
tResult Process(adtf::base::tNanoSeconds tmTrigger, adtf::streaming::IRunner* /*pRunner*/) override
{
++m_nTriggerCounter;
std::lock_guard<std::mutex> oGuard(m_oSubStreamsLock);
for (const auto& nSubStreamId: m_oEnabledSubStreams)
{
adtf::streaming::output_sample_data<uint32_t> oNewData(tmTrigger, m_nTriggerCounter, nSubStreamId);
m_pWriter->Write(oNewData.Release());
}
}
private:
adtf::streaming::requestable_writer<>* m_pWriter = nullptr;
std::mutex m_oSubStreamsLock;
std::set<uint32_t> m_oEnabledSubStreams;
uint32_t m_nTriggerCounter = 0;
};
Parameters
[in,out]fnEnableCalled when the first consumer request samples of a substream.
[in,out]fnDisableCalled when the last consumer cancels its request for samples of a substream.

◆ SetType()

template<typename BaseWriter = adtf::streaming::cSampleWriter>
tResult adtf::streaming::hollow::requestable_writer< BaseWriter >::SetType ( const ucom::ant::iobject_ptr< const ant::IStreamType > & pStreamType)
inlineoverridevirtual

Sets the initial stream type of a streamer.

Parameters
[in]pStreamTypeThe stream type
Returns
Standard result.

Reimplemented from adtf::streaming::flash::cSampleWriter.


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