ADTF  3.18.4
Source Code for Demo Dynamic Properties
Location
./src/examples/src/adtf/filters/standard_filters/demo_dynamic_properties/
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:
  • how to use properties
Header
#pragma once
//*************************************************************************************************
#define CID_DEMO_DYNAMIC_PROPERTIES "demo_dynamic_properties.filter.adtf.cid"
using namespace adtf_util;
using namespace ddl;
using namespace adtf::ucom;
using namespace adtf::base;
using namespace adtf::streaming;
using namespace adtf::mediadescription;
using namespace adtf::filter;
class cDynamicPropertiesFilter : public cFilter
{
public:
ADTF_CLASS_ID_NAME(cDynamicPropertiesFilter,
CID_DEMO_DYNAMIC_PROPERTIES,
"Demo Dynamic Properties");
cDynamicPropertiesFilter();
virtual ~cDynamicPropertiesFilter() = default;
private:
class cProperties
{
public:
property_variable<std::string> m_propFilename = {};
cDynamicPropertiesFilter& m_oFilter;
std::string m_strPropertyName;
public:
cProperties(cDynamicPropertiesFilter& oFilter, std::string strPropertyName);
~cProperties();
};
std::list<std::unique_ptr<cProperties>> m_lstProperties;
property_variable<uint16_t> m_nDynamicPropertyByProperty = 0;
std::list<std::unique_ptr<cProperties>> m_lstPropertiesFromFile;
property_variable<cFilename> m_nDynamicPropertyByFile;
};
#define ADTF_CLASS_ID_NAME(_class, _strcid, _strclabel)
Common macro to enable correct treatment of class identifier AND Class Name by IClassInfo.
Definition: class_id.h:33
Namespace for the ADTF Base SDK.
Namespace for the ADTF Filter SDK.
Namespace for the ADTF Media Description 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 "demo_dynamic_properties.h"
#include <string>
#include <fstream>
ADTF_PLUGIN("Demo Dynamic Properties Filter Plugin", cDynamicPropertiesFilter);
cDynamicPropertiesFilter::cProperties::cProperties(cDynamicPropertiesFilter& oFilter, std::string strPropertyName):
m_oFilter(oFilter),
m_strPropertyName(strPropertyName)
{
//Register Properties
m_propFilename.SetDescription("Select a single file.");
m_oFilter.RegisterPropertyVariable(m_strPropertyName.c_str(), m_propFilename);
}
cDynamicPropertiesFilter::cProperties::~cProperties()
{
object_ptr<IProperties> pProperties;
if (IS_OK(m_oFilter.GetProperties(pProperties)))
{
pProperties->RemoveProperty(m_strPropertyName.c_str());
}
}
//This is to initialize the cDynamicPropertiesFilter
cDynamicPropertiesFilter::cDynamicPropertiesFilter()
{
m_nDynamicPropertyByProperty.SetDescription("Amount of property instances");
m_nDynamicPropertyByProperty.SetPropertyChangedCallback([this]()
{
m_lstProperties.clear();
for (uint32_t nIndex = 0; nIndex < m_nDynamicPropertyByProperty; nIndex++)
{
m_lstProperties.push_back(std::make_unique<cProperties>(*this, std::string("by_property_") + std::to_string(nIndex)));
}
});
RegisterPropertyVariable("dynamic_property_by_property", m_nDynamicPropertyByProperty);
m_nDynamicPropertyByFile.SetDescription("A text file with properties per line");
m_nDynamicPropertyByFile.SetPropertyChangedCallback([this]()
{
m_lstPropertiesFromFile.clear();
std::ifstream oFile(m_nDynamicPropertyByFile->GetPtr());
std::string strPropertyByLine;
while (std::getline(oFile, strPropertyByLine))
{
m_lstPropertiesFromFile.push_back(std::make_unique<cProperties>(*this, strPropertyByLine));
}
});
RegisterPropertyVariable("dynamic_property_by_file", m_nDynamicPropertyByFile);
// sets a short description for the component
set_description(*this, "Use this filter to provide a dynamic amount of properties.");
// set help link to jump to documentation from ADTF Configuration Editor
set_help_link(*this, "$(ADTF_DIR)/doc/adtf_html/page_demo_dynamic_properties.html");
}
Copyright © Audi Electronics Venture GmbH.
#define ADTF_PLUGIN(__plugin_identifier,...)
The ADTF Plugin Macro will add the code of a adtf::ucom::ant::IPlugin implementation.
Definition: adtf_plugin.h:22
cString to_string(const tResult &i_oResult, eResultFormatFlags i_eFormatFlags=eResultFormatFlags::RFF_DisableNone, const tChar *i_strFormat=nullptr)
Copy all information of an assigned result object to a (formatted) string.
void set_description(base::ant::IConfiguration &oConfig, const char *strDescription)
Sets description information.
void set_help_link(base::ant::IConfiguration &oConfig, const char *strUrl)
Set the link to the corresponding help/documentation.