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