9 #include <adtf_platform_inc.h>
10 #include <adtf_base.h>
79 tResult
StoreProperty(adtf_util::cString strPrefix, adtf_util::cDOMElement* pConfig);
122 template <
typename T>
186 template <
typename T>
188 m_strConfigFile(
"$(ADTF_GRAPH_DIR)/$(THIS_OBJECT_FULL_NAME)"),
192 m_strConfigFile.SetDescription(
"Path to configuration file for runtime settings.");
193 T::RegisterPropertyVariable(
"runtime_config_file_path",
m_strConfigFile);
196 template <
typename T>
202 template <
typename T>
205 return static_cast<adtf_util::cFilename
>(m_strConfigFile).MakeNativeSlashes();
208 template <
typename T>
211 if (m_oRuntimeConfig.GetConfigFile().Empty)
213 m_oRuntimeConfig.SetConfigFile(GetConfigFile());
216 RETURN_IF_FAILED(m_oRuntimeConfig.ClearAllProperties());
218 RETURN_IF_FAILED(this->SaveConfiguration(&m_oRuntimeConfig));
219 if IS_FAILED(m_oRuntimeConfig.Save())
221 RETURN_AND_LOG_ERROR_STR(ERR_FAILED,
"Runtime configuration could not be stored");
225 LOG_INFO(
"Runtime configuration was stored to file");
230 template <
typename T>
233 if (!adtf_util::cFileSystem::Exists(GetConfigFile()))
235 RETURN_ERROR_DESC(ERR_FILE_NOT_FOUND,
236 "Runtime configuration file '%s' does not exist",
static_cast<adtf_util::cString
>(m_strConfigFile).GetPtr());
239 if (m_oRuntimeConfig.GetConfigFile().Empty)
241 m_oRuntimeConfig.SetConfigFile(GetConfigFile());
244 RETURN_IF_FAILED(m_oRuntimeConfig.Load());
246 if IS_FAILED(this->LoadConfiguration(&m_oRuntimeConfig))
248 RETURN_ERROR_DESC(ERR_FAILED,
"Runtime configuration could not be read");
Interface for loading and storing runtime configuration properties to and from passed adtf::base::ICo...
virtual tResult LoadConfiguration(adtf::base::IConfiguration *pRuntimeConfig)=0
Implementation has to get all properties from pRuntimeConfig (contains all loaded properties from run...
virtual tResult SaveConfiguration(adtf::base::IConfiguration *pRuntimeConfig)=0
Implementation has to add all properties to be written to runtime configuration file to pRuntimeConfi...
Class is a adtf::base::configuration that allows the storing and loading of all contained properties ...
tResult Save()
Saves all properties of this instance to the configured xml file.
tResult ClearAllProperties()
Clears all properties currently stored in cRuntimeConfigFile.
adtf_util::cFilename m_strConfigFile
path to the xml file
cRuntimeConfigFile(const adtf_util::cFilename &strConfigFile)
Constructor.
tVoid SetConfigFile(const adtf_util::cFilename &strFilename)
Setter for xml config file to load and store runtime configuration.
adtf_util::cFilename GetConfigFile()
Setter for xml config file to load and store runtime configuration.
tResult StoreProperty(adtf_util::cString strPrefix, adtf_util::cDOMElement *pConfig)
Stores all properties of this instance in DOM pConfig.
tResult Load()
Loads all properties from the configured xml file and stores it to this instance.
Template class enables the loading and storing of runtime configuration data.
adtf::base::property_variable< adtf_util::cFilename > m_strConfigFile
CE property_variable storing path of runtime configuration file.
adtf_util::cString GetConfigFile()
Getter for path of configuration file.
virtual tResult LoadConfiguration(adtf::base::IConfiguration *pRuntimeConfig)=0
Callback to be implemented by user of runtime_configuration.
tResult SaveRuntimeConfigFile()
Saves all properties to the file configured with adtf-property runtime_config_file_path.
tResult LoadRuntimeConfigFile()
Loads all properties from the file configured with adtf-property runtime_config_file_path.
virtual tResult SaveConfiguration(adtf::base::IConfiguration *pRuntimeConfig)=0
Callback to be implemented by user of runtime_configuration.
cRuntimeConfigFile m_oRuntimeConfig
actual runtime configuration