ADTF  3.18.2
Source Code for Demo Legacy Data Trigger Plugin
Location
./src/examples/src/adtf/filters/adtf2_legacy/legacy_data_filter/
Namespace for entire ADTF SDK.
Build Environment
To see how to set up the build environment have a look at ADTF CMake Environment
this implementation shows:
Remarks
Header
#ifndef _DEMO_DATA_TRIGGER_FUNCTION_FILTER_H_
#define _DEMO_DATA_TRIGGER_FUNCTION_FILTER_H_
//*************************************************************************************************
#define CID_LEGACY_DATA_FILTER "demo_legacy_data_trigger.filter.adtf.cid"
using namespace adtf_util;
using namespace adtf::ucom;
using namespace adtf::streaming;
using namespace adtf::filter;
using namespace adtf::adtf2;
class cDemoLegacyDataFilter: public cLegacyFilter
{
private:
cLegacyInputPin m_oInputPin;
cLegacyOutputPin m_oOutputPin;
double m_fFactor;
public:
cDemoLegacyDataFilter();
~cDemoLegacyDataFilter();
tResult Init(tInitStage eStage) override;
tResult Start() override;
tResult Stop() override;
tResult Shutdown(tInitStage eStage) override;
protected:
tResult OnSampleReceived(cLegacyInputPin* pPin,
const iobject_ptr<const ISample>& pSample) override;
tResult OnTypeChanged(cLegacyInputPin* pPin,
const iobject_ptr<const IStreamType>& pType) override;
};
//*************************************************************************************************
#endif // _DEMO_DATA_TRIGGER_FUNCTION_FILTER_H_
Namespace providing ADTF 2 legacy functionality of the ADTF 2 Support SDK.
Namespace for the ADTF Filter SDK.
Namespace for the ADTF Streaming SDK.
Namespace for the ADTF uCOM3 SDK.
ADTF adtf_util Namespace - Within adtf this is used as adtf::util or adtf_util and also defined as A_...
Implementation
#include <adtf3.h>
#include <adtf2_support.h>
#include "demo_legacy_data_filter.h"
ADTF_LEGACY_FILTER_PLUGIN(CID_LEGACY_DATA_FILTER,
"Demo Legacy Data Trigger",
cDemoLegacyDataFilter);
cDemoLegacyDataFilter::cDemoLegacyDataFilter()
{
SetPropertyFloat("factor", 1.0);
// sets a short description for the component
set_description(*this, "Use this legacy filter for transmitting a received value changed by a 'factor' property.");
}
cDemoLegacyDataFilter::~cDemoLegacyDataFilter()
{
}
tResult cDemoLegacyDataFilter::Init(tInitStage eStage)
{
RETURN_IF_FAILED(cLegacyFilter::Init(eStage));
if (eStage == tInitStage::StageFirst)
{
object_ptr<const IStreamType> pType = make_object_ptr<stream_type_plain<double>>();
RETURN_IF_FAILED(m_oInputPin.Create("input", pType));
RETURN_IF_FAILED(RegisterPin(m_oInputPin));
RETURN_IF_FAILED(m_oOutputPin.Create("output", pType));
RETURN_IF_FAILED(RegisterPin(m_oOutputPin));
}
else if (eStage == tInitStage::StageNormal)
{
m_fFactor = GetPropertyFloat("factor");
}
}
tResult cDemoLegacyDataFilter::Start()
{
return cLegacyFilter::Start();
}
tResult cDemoLegacyDataFilter::OnSampleReceived(cLegacyInputPin* /* pPin */,
const iobject_ptr<const ISample>& pSample)
{
object_ptr<ISample> pOutputSample;
RETURN_IF_FAILED(alloc_sample(pOutputSample, pSample->GetTime()));
{
__sample_write_lock(pOutputSample, double, pOutputValue);
__sample_read_lock(pSample, double, pInputValue);
*pOutputValue = *pInputValue * m_fFactor;
}
return m_oOutputPin.Transmit(object_ptr<const ISample>(pOutputSample));
}
tResult cDemoLegacyDataFilter::OnTypeChanged(cLegacyInputPin* pPin,
const iobject_ptr<const IStreamType>& pType)
{
return cLegacyFilter::OnTypeChanged(pPin, pType);
}
tResult cDemoLegacyDataFilter::Stop()
{
return cLegacyFilter::Stop();
}
tResult cDemoLegacyDataFilter::Shutdown(tInitStage eStage)
{
return cLegacyFilter::Shutdown(eStage);
}
Copyright © Audi Electronics Venture GmbH.
#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 __sample_read_lock(__sample, __type, __variable)
Compatibility macro to gain read access to a sample.
#define __sample_write_lock(__sample, __type, __variable)
Compatibility macro to gain write access to a sample.
#define ADTF_LEGACY_FILTER_PLUGIN(_class_identifier_, _class_name_, _triggerfunction_)
Macro to define an ADTF 3 Plugin that provides a legacy Filter.
tResult alloc_sample(ucom::ant::iobject_ptr< ucom::ant::IObject > &pSampleObject, const char *strSampleCID)
Helper Function to get a Sample Instance through the adtf::ucom::ant::IRuntime.
void set_description(base::ant::IConfiguration &oConfig, const char *strDescription)
Sets description information.