2022-06-18 00:46:47 +00:00
|
|
|
#include "values.hpp"
|
|
|
|
|
2023-04-22 18:40:17 +00:00
|
|
|
#include <stdexcept>
|
|
|
|
|
2022-06-18 00:46:47 +00:00
|
|
|
namespace Settings
|
|
|
|
{
|
2023-10-31 10:05:54 +00:00
|
|
|
std::unique_ptr<Index> StaticValues::sIndex;
|
|
|
|
std::unique_ptr<Values> StaticValues::sDefaultValues;
|
|
|
|
std::unique_ptr<Values> StaticValues::sValues;
|
2022-06-18 00:46:47 +00:00
|
|
|
|
2023-04-10 15:24:57 +00:00
|
|
|
void StaticValues::initDefaults()
|
2022-06-18 00:46:47 +00:00
|
|
|
{
|
2023-10-31 10:05:54 +00:00
|
|
|
if (sDefaultValues != nullptr)
|
|
|
|
throw std::logic_error("Default settings are already initialized");
|
|
|
|
sIndex = std::make_unique<Index>();
|
|
|
|
sDefaultValues = std::make_unique<Values>(*sIndex);
|
2022-06-18 00:46:47 +00:00
|
|
|
}
|
2023-04-22 18:40:17 +00:00
|
|
|
|
2023-04-10 15:24:57 +00:00
|
|
|
void StaticValues::init()
|
2023-04-22 18:40:17 +00:00
|
|
|
{
|
2023-10-31 10:05:54 +00:00
|
|
|
if (sDefaultValues == nullptr)
|
2023-04-22 18:40:17 +00:00
|
|
|
throw std::logic_error("Default settings are not initialized");
|
2023-10-31 10:05:54 +00:00
|
|
|
sValues = std::make_unique<Values>(std::move(*sDefaultValues));
|
|
|
|
}
|
|
|
|
|
|
|
|
void StaticValues::clear()
|
|
|
|
{
|
|
|
|
sValues = nullptr;
|
|
|
|
sDefaultValues = nullptr;
|
|
|
|
sIndex = nullptr;
|
2023-04-22 18:40:17 +00:00
|
|
|
}
|
2022-06-18 00:46:47 +00:00
|
|
|
}
|