refactor: Use shared_ptr for Bar/Opts

This commit is contained in:
Michael Carlberg
2016-06-29 12:42:54 +02:00
parent f406f1eb9f
commit 80e6936cdc
7 changed files with 24 additions and 20 deletions

View File

@ -28,21 +28,21 @@
#endif
std::shared_ptr<Bar> bar;
std::shared_ptr<Bar> &get_bar()
std::shared_ptr<Bar> get_bar()
{
if (bar == nullptr)
bar = std::make_shared<Bar>();
return bar;
}
const Options& bar_opts() {
return *bar->opts.get();
std::shared_ptr<Options> bar_opts() {
return bar->opts;
}
/**
* Bar constructor
*/
Bar::Bar() : config_path(config::get_bar_path()), opts(std::make_unique<Options>())
Bar::Bar() : config_path(config::get_bar_path()), opts(std::make_shared<Options>())
{
struct Options defaults;