From 19b7f81d96f5dea2d43dc26edd297266a20e5858 Mon Sep 17 00:00:00 2001 From: Valerio Pastore Date: Thu, 11 Jan 2024 20:23:19 +0100 Subject: [PATCH 1/3] adding doxygen --- include/Yaml_Conf.h | 15 ++++++++++++++- src/Yaml_Conf.cpp | 26 ++++++++++++++++++++------ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/include/Yaml_Conf.h b/include/Yaml_Conf.h index af3a0c2..c5fa776 100644 --- a/include/Yaml_Conf.h +++ b/include/Yaml_Conf.h @@ -6,6 +6,10 @@ namespace inaf::oasbo::Configurators { +/** + * @brief The YamlConfigurator class is a subclass of BaseConfigurator that provides functionality for reading and writing YAML configuration files. + * It inherits from the BaseConfigurator class. Check Base_Configurator.h for more information. + */ class YamlConfigurator: public BaseConfigurator { protected: YAML::Node file; @@ -13,13 +17,22 @@ protected: public: std::string path; + + /** + * @brief Constructs a YamlConfigurator object with the specified path to the YAML configuration file. + * @param path The path to the YAML configuration file. + */ YamlConfigurator(std::string path); int readConfigFromSource() override; + int readConfigFromSource(std::string target) override; + int pushConfigToSource() override; + int pushConfigToSource(std::string target) override; - int insert(std::map, std::string target) override; + int insert(std::map, std::string target) override; }; + } diff --git a/src/Yaml_Conf.cpp b/src/Yaml_Conf.cpp index 6bfe29f..66bd2fc 100644 --- a/src/Yaml_Conf.cpp +++ b/src/Yaml_Conf.cpp @@ -39,8 +39,7 @@ void YamlConfigurator::load(std::string path) { } /** - - Updates the YAML configuration file by adding new configuration entries for the target key. + @brief Updates the YAML configuration file by adding new configuration entries for the target key. It also removes old configurations corresponding to the target key. @param target The target key for which to add and remove configuration entries. */ @@ -84,11 +83,11 @@ int YamlConfigurator::pushConfigToSource(std::string target) { for (; pos < file_content.size(); pos++) { if (file_content[pos][0] != '-') { line = file_content[pos]; - // Elimina gli spazi vuoti all'inizio della stringa e Ferma l'analisi al carattere ":" escluso + // Remove leading whitespace from the string and stop analysis at the ":" character (excluding it) line = line.erase(0, line.find_first_not_of(' ')).substr(0, line.find(':')); boost::to_lower(line); - bool found = false; // Controlla se la riga è stata sostituita dalla nuova conf + bool found = false; // Checks if the line has been replaced by the new configuration for (auto key : filteredMap) { if (key.first.compare(line) == 0) { found = true; @@ -164,12 +163,27 @@ int YamlConfigurator::readConfigFromSource() { if (file.IsNull()) return -1; try { - // Itera sugli elementi del documento YAML + // Iterate over the elements of the YAML document + for (const auto &element : file) { + for (const auto &pair : element) { + std::string elementName = element.first.as(); + boost::to_lower(elementName); + // If the element is a map, extract the keys and values + if (pair.second.IsMap()) { + for (const auto &subPair : pair.second) { + std::string key = elementName + "_" + + subPair.first.as(); + std::string value = subPair.second.as(); + config[key] = value; + } + } + } + } for (const auto &element : file) { for (const auto &pair : element) { std::string elementName = element.first.as(); boost::to_lower(elementName); - // Se l'elemento è una mappa, estrai le chiavi e i valori + // If the element is a map, extract the keys and values if (pair.second.IsMap()) { for (const auto &subPair : pair.second) { std::string key = elementName + "_" -- GitLab From afff41dfe3b9f06ebdd1240d820df2f1cb71d34a Mon Sep 17 00:00:00 2001 From: valerio pastore Date: Thu, 11 Jan 2024 20:53:11 +0100 Subject: [PATCH 2/3] . --- deps/Base-DAQ | 2 +- include/Yaml_Conf.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deps/Base-DAQ b/deps/Base-DAQ index 8a0ea2d..f81453c 160000 --- a/deps/Base-DAQ +++ b/deps/Base-DAQ @@ -1 +1 @@ -Subproject commit 8a0ea2d0e699863df5fe1c91caf2d7b0855957be +Subproject commit f81453c9f6d51b1cce2ce0507264c69f5dddc725 diff --git a/include/Yaml_Conf.h b/include/Yaml_Conf.h index c5fa776..47447a5 100644 --- a/include/Yaml_Conf.h +++ b/include/Yaml_Conf.h @@ -29,7 +29,7 @@ public: int readConfigFromSource(std::string target) override; int pushConfigToSource() override; - + int pushConfigToSource(std::string target) override; int insert(std::map, std::string target) override; -- GitLab From 619b119743e1f4de6313910e037447f5fe2876d4 Mon Sep 17 00:00:00 2001 From: valerio pastore Date: Fri, 12 Jan 2024 20:16:21 +0100 Subject: [PATCH 3/3] . --- deps/Base-DAQ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/Base-DAQ b/deps/Base-DAQ index f81453c..a00f9a2 160000 --- a/deps/Base-DAQ +++ b/deps/Base-DAQ @@ -1 +1 @@ -Subproject commit f81453c9f6d51b1cce2ce0507264c69f5dddc725 +Subproject commit a00f9a27afbf5f75dab7db2368b9b9b6fcb395e1 -- GitLab