Skip to content
Snippets Groups Projects
Commit 1574d50e authored by Stefan Spettel's avatar Stefan Spettel
Browse files

style(pcf): Fix comments in config.hpp and add comments in config_types.hpp

parent 622c539d
No related branches found
No related tags found
1 merge request!18Created generic configuration framework to be used by all NFs
......@@ -46,7 +46,7 @@ const std::string LOGGER_NAME = "config ";
class config_iface {
public:
/**
* Set a string configuration, adds if not existing or overrides if exists
* Sets a string configuration, adds if not existing or overrides if exists
* Takes ownership of configuration, becomes null after call to this function
* @param name name of the configuration
* @param val value of the configuration
......@@ -55,14 +55,14 @@ class config_iface {
const std::string& name, std::unique_ptr<config_type> val) = 0;
/**
* Set a configuration of any type with name to be mandatory, used for
* Sets a configuration of any type with name to be mandatory, used for
* validation
* @param name name of the configuration
*/
virtual void set_configuration_mandatory(const std::string& name) = 0;
/**
* Validate the configuration:
* Validates the configuration:
* - All configurations set as mandatory must be present
* - All present configurations must pass their type-specific validation
* @return True if validation passed, false otherwise
......@@ -79,7 +79,7 @@ class config_iface {
// members Annoying that I cannot have a virtual template method just called
// "get"
/**
* Get a string base configuration
* Gets a string base configuration
* @throws std::invalid_argument when name does not exist in configuration
* @param name of the configuration
* @return value
......@@ -88,7 +88,7 @@ class config_iface {
const std::string& name) const = 0;
/**
* Get a boolean configuration
* Gets a boolean configuration
* @throws std::invalid_argument when name does not exist in configuration
* @param name of the configuration
* @return value
......@@ -97,7 +97,7 @@ class config_iface {
const std::string& name) const = 0;
/**
* Get a SBI interface configuration
* Gets a SBI interface configuration
* @throws std::invalid_argument when name does not exist in configuration
* @param name of the configuration
* @return value
......@@ -106,7 +106,7 @@ class config_iface {
const std::string& name) const = 0;
/**
* Get a local SBI interface configuration
* Gets a local SBI interface configuration
* @throws std::invalid_argument when name does not exist in configuration
* @param name of the configuration
* @return value
......@@ -115,7 +115,7 @@ class config_iface {
const std::string& name) const = 0;
/**
* Get a local interface configuration
* Gets a local interface configuration
* @throws std::invalid_argument when name does not exist in configuration
* @param name of the configuration
* @return value
......@@ -124,7 +124,7 @@ class config_iface {
const std::string& name) const = 0;
/**
* Display the to_string method to the config logger
* Displays the to_string method to the config logger
*/
virtual void display() const = 0;
......@@ -150,7 +150,7 @@ class config : public config_iface {
[[nodiscard]] std::string to_string() const override;
/**
* Get configuration of type T, must be derived from conf_type
* Gets configuration of type T, must be derived from conf_type
* @tparam T sub_type of conf_type
* @param name of the configuration
* @throws std::invalid_argument when name does not exist in configuration
......
......@@ -45,15 +45,39 @@ enum class config_type_e { string, option, sbi, local, invalid };
class config_type {
public:
/**
* Returns a string representation of the config. The indent is prepended at each line
* @param indent to be prepended
* @return string representation
*/
[[nodiscard]] virtual std::string to_string(
const std::string& indent) const = 0;
/**
* Validates the configuration and marks the configuration as set if successful
* @return true if validation successful, false otherwise
*/
[[nodiscard]] virtual bool validate() = 0;
/**
* Gets the config type of this config
* @return config_type_e
*/
[[nodiscard]] virtual config_type_e get_config_type() const = 0;
/**
* Checks if the configuration is set. Configuration is not set if it has not been
* validated.
* @return true if set, false otherwise
*/
[[nodiscard]] virtual bool is_set() const;
/**
* Helper function to match a regex
* @param value to match again
* @param regex that is used for the matching
* @return true if matched, false otherwise
*/
static bool matches_regex(const std::string& value, const std::string& regex);
virtual ~config_type() = default;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment