Commit 0aa14c84 authored by louiz’'s avatar louiz’

Improve the config singleton

parent 1994c5b5
...@@ -19,13 +19,15 @@ ...@@ -19,13 +19,15 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <functional> #include <functional>
#include <memory>
typedef std::function<void()> t_config_changed_callback; typedef std::function<void()> t_config_changed_callback;
class Config class Config
{ {
public: public:
~Config(){}; Config() = default;
~Config() = default;
/** /**
* returns a value from the config. If it doesn’t exist, use * returns a value from the config. If it doesn’t exist, use
* the second argument as the default. * the second argument as the default.
...@@ -69,14 +71,12 @@ public: ...@@ -69,14 +71,12 @@ public:
/** /**
* The uniq config instance. * The uniq config instance.
*/ */
static Config* instance; static std::unique_ptr<Config> instance;
/** /**
* Close the config file, saving it to the file is save == true. * Close the config file, saving it to the file is save == true.
*/ */
static void close(bool save = false); static void close(bool save = false);
private:
Config(){};
Config(const Config &){}; Config(const Config &){};
/** /**
* Write all the config values into the configuration file * Write all the config values into the configuration file
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment