Shows how to use dynamic properties.
#pragma once
#ifndef ADTF_EXAMPLES_CID
#define ADTF_EXAMPLES_CID ".local.cid"
#endif
#define CID_DEMO_DYNAMIC_PROPERTIES "demo_dynamic_properties.filter" ADTF_EXAMPLES_CID
{
public:
CID_DEMO_DYNAMIC_PROPERTIES,
"Demo Dynamic Properties");
cDynamicPropertiesFilter();
~cDynamicPropertiesFilter() override;
private:
class cProperties
{
public:
cDynamicPropertiesFilter& m_oFilter;
std::string m_strPropertyName;
public:
cProperties(cDynamicPropertiesFilter& oFilter, std::string strPropertyName);
~cProperties();
};
std::list<std::unique_ptr<cProperties>> m_lstProperties;
std::list<std::unique_ptr<cProperties>> m_lstPropertiesFromFile;
};
#define ADTF_CLASS_ID_NAME(_class, _strcid, _strclabel)
Definition class_id.h:33
Property Variable template for the given T. A Property Variable will store a copy of a property value...
Definition configuration.h:808
#include "demo_dynamic_properties.h"
#include <string>
#include <fstream>
using namespace adtf_util;
ADTF_PLUGIN(
"Demo Dynamic Properties Filter Plugin", cDynamicPropertiesFilter);
cDynamicPropertiesFilter::cProperties::cProperties(cDynamicPropertiesFilter& oFilter, std::string strPropertyName):
m_oFilter(oFilter),
m_strPropertyName(strPropertyName)
{
m_propFilename.SetDescription("Select a single file.");
m_oFilter.RegisterPropertyVariable(m_strPropertyName.c_str(), m_propFilename);
}
cDynamicPropertiesFilter::cProperties::~cProperties()
{
if (
IS_OK(m_oFilter.GetProperties(pProperties)))
{
pProperties->RemoveProperty(m_strPropertyName.c_str());
}
}
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);
set_description(*
this,
"Use this filter to provide a dynamic amount of properties.");
set_help_link(*
this,
"$(ADTF_DIR)/doc/html/page_demo_dynamic_properties.html");
}
cDynamicPropertiesFilter::~cDynamicPropertiesFilter() = default;
#define ADTF_PLUGIN(__plugin_identifier,...)
Definition adtf_plugin.h:29
#define IS_OK(s)
Check if result is OK.
Definition result.h:17
Definition object_ptr.h:384
Namespace for the ADTF Base SDK.
Definition adtf_base_type_traits.h:13
Namespace for the ADTF Filter SDK.
Definition configurable_runner.h:18
Namespace for the ADTF Streaming SDK.
Definition bindingproxyinport.h:14
void set_help_link(base::ant::IConfiguration &oConfig, const char *strUrl)
void set_description(base::ant::IConfiguration &oConfig, const char *strDescription)
Namespace for the ADTF uCOM SDK.
Definition adtf_system.h:324
definition of the ddl namespace
Definition codec.h:21