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-04-10 15:24:57 +00:00
|
|
|
Index* StaticValues::sIndex = nullptr;
|
|
|
|
Values* StaticValues::sValues = nullptr;
|
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-04-10 15:24:57 +00:00
|
|
|
if (sValues != nullptr)
|
2023-04-22 18:40:17 +00:00
|
|
|
throw std::logic_error("Default settings already initialized");
|
2023-04-10 15:24:57 +00:00
|
|
|
static Index index;
|
|
|
|
static Values values(index);
|
|
|
|
sIndex = &index;
|
|
|
|
sValues = &values;
|
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-04-10 15:24:57 +00:00
|
|
|
if (sValues == nullptr)
|
2023-04-22 18:40:17 +00:00
|
|
|
throw std::logic_error("Default settings are not initialized");
|
2023-04-10 15:24:57 +00:00
|
|
|
static Values values(std::move(*sValues));
|
|
|
|
sValues = &values;
|
2023-04-22 18:40:17 +00:00
|
|
|
}
|
2022-06-18 00:46:47 +00:00
|
|
|
}
|