I have created a config
class which loads configuration from a config YAML
. I have created vector containers for each type
// Pseudo Code
class config
{
private:
std::vector<std::string> c_name;
public:
config(yaml_file_path)
{
// Handles reading from yaml and loading data to c_name container.
load(yaml_file_path);
}
std::vector<std::string> get_name()
{
return c_name;
}
};
I use this object in other class to get the name config.
class loadConfig
{
config cfg(yaml_file_path);
std::vector<std::string> name = cfg.get_name();
// Further use of vector name like checks.
}
Question : What would be better?(as code practice and execution time and/or memory space)
- Using
get_name()
function in various places in code. OR - Copying value in container, as I have done?
Aucun commentaire:
Enregistrer un commentaire