ADTF_DISPLAY_TOOLBOX  3.8.0 (ADTF 3.14.3)
adtf_display_toolbox_base.h
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include "runtimeconfig.h"
10 
11 #include <adtfbase/configuration_intf.h>
12 #include <adtfbase/configuration.h>
13 
14 namespace adtf
15 {
16 namespace disptb
17 {
18 
20 static constexpr char property_separator[] = ".";
21 
29 std::string BuildPropertyName(std::string const& prefix, std::string const& prop_name);
30 
31 
41 template<typename T>
42 void AttachPropertyEntry(const tChar* prop_name_prefix, const tChar* prop_name, T const& prop_val, adtf::base::ant::IConfiguration& configuration)
43 {
44  std::string full_prop_name = BuildPropertyName(prop_name_prefix, prop_name);
45  adtf::base::ant::set_property<T>(configuration, full_prop_name.c_str(), prop_val);
46 }
47 
57 template<typename T>
58 T GetPropertyValue(std::string const& prop_name_prefix, std::string const& prop_name, adtf::base::ant::IConfiguration const& configuration)
59 {
60  std::string full_prop_name = BuildPropertyName(prop_name_prefix, prop_name);
61  return adtf::base::ant::get_property<T>(configuration, full_prop_name.c_str());
62 }
63 
72 bool HasProperty(std::string const& prop_name_prefix, std::string const& prop_name, adtf::base::ant::IConfiguration const& configuration);
73 
74 
85 template<typename ValueType>
86 ValueType RestorePropertyValue(std::string const & prefix, std::string const & prop_name, adtf::base::ant::IConfiguration const & configuration)
87 {
88  if (!HasProperty(prefix, prop_name, configuration))
89  {
90  std::string info = "Could not find property '";
91  info.append(adtf::disptb::BuildPropertyName(prefix, prop_name));
92  info.append("' for restoring its value.\n");
93  LOG_WARNING(info.c_str());
94  }
95 
96  // call GetPropertyValue always, it will deliver a default value in case property does not exist
97  return GetPropertyValue<ValueType>(prefix, prop_name, configuration);
98 }
99 
100 
101 } // disptb
102 
103 } // adtf
T GetPropertyValue(std::string const &prop_name_prefix, std::string const &prop_name, adtf::base::ant::IConfiguration const &configuration)
Retrieves the value of a property from a given configuration.
static constexpr char property_separator[]
Define a separator for properties.
std::string BuildPropertyName(std::string const &prefix, std::string const &prop_name)
Rule to build a full property name, based on its prefix and (base) name.
bool HasProperty(std::string const &prop_name_prefix, std::string const &prop_name, adtf::base::ant::IConfiguration const &configuration)
Query whether a configuration contains a property.
ValueType RestorePropertyValue(std::string const &prefix, std::string const &prop_name, adtf::base::ant::IConfiguration const &configuration)
Restores the value of a property from a given configuration.
void AttachPropertyEntry(const tChar *prop_name_prefix, const tChar *prop_name, T const &prop_val, adtf::base::ant::IConfiguration &configuration)
Attaches a property and its value to a given configuration.
Main namespace.
Copyright © Audi Electronics Venture GmbH.