draconisplusplus/src/config/config.h

67 lines
1.8 KiB
C
Raw Normal View History

2024-06-07 04:23:11 -04:00
#pragma once
2024-06-01 06:59:01 -04:00
#include <fmt/core.h>
#include <rfl.hpp>
2024-06-05 19:04:53 -04:00
#include <rfl/toml.hpp>
2024-05-31 22:59:00 -04:00
#include <string>
2024-06-14 01:41:59 -04:00
#include "util/macros.h"
#include "weather.h"
2024-05-31 22:59:00 -04:00
2024-06-14 01:41:59 -04:00
// TODO: Make config values optional and supply defaults
2024-05-31 22:59:00 -04:00
class General {
private:
2024-06-07 04:23:11 -04:00
std::string m_Name;
2024-05-31 22:59:00 -04:00
public:
2024-06-07 04:23:11 -04:00
General(std::string name);
2024-05-31 22:59:00 -04:00
2024-06-09 20:14:51 -04:00
[[nodiscard]] fn getName() const -> const std::string;
2024-06-01 06:59:01 -04:00
};
2024-05-31 22:59:00 -04:00
class NowPlaying {
private:
2024-06-01 06:59:01 -04:00
bool m_Enabled;
2024-05-31 22:59:00 -04:00
public:
2024-06-02 06:03:21 -04:00
NowPlaying(bool enabled);
2024-05-31 22:59:00 -04:00
2024-06-09 20:14:51 -04:00
[[nodiscard]] fn getEnabled() const -> bool;
2024-06-01 06:59:01 -04:00
};
2024-05-31 22:59:00 -04:00
class Config {
private:
2024-06-09 20:14:51 -04:00
General m_General;
2024-06-01 06:59:01 -04:00
NowPlaying m_NowPlaying;
2024-06-09 20:14:51 -04:00
Weather m_Weather;
2024-05-31 22:59:00 -04:00
2024-06-01 06:59:01 -04:00
public:
Config(General general, NowPlaying now_playing, Weather weather);
2024-06-09 20:14:51 -04:00
static fn getInstance() -> const Config&;
2024-05-31 22:59:00 -04:00
2024-06-09 20:14:51 -04:00
[[nodiscard]] fn getWeather() const -> const Weather;
[[nodiscard]] fn getGeneral() const -> const General;
[[nodiscard]] fn getNowPlaying() const -> const NowPlaying;
2024-05-31 22:59:00 -04:00
};
2024-06-01 06:59:01 -04:00
2024-06-15 16:57:16 -04:00
// reflect-cpp Stuff
2024-06-15 16:38:37 -04:00
DEF_IMPL(General, general, std::string name)
DEF_IMPL(NowPlaying, now_playing, std::optional<bool> enabled)
DEF_IMPL(Config, config, General general; NowPlaying now_playing; Weather weather)
2024-06-01 06:59:01 -04:00
namespace rfl::parsing {
template <class ReaderType, class WriterType, class ProcessorsType>
struct Parser<ReaderType, WriterType, General, ProcessorsType>
2024-06-15 16:38:37 -04:00
: public CustomParser<ReaderType, WriterType, ProcessorsType, General, GeneralImpl> {};
2024-06-01 06:59:01 -04:00
template <class ReaderType, class WriterType, class ProcessorsType>
struct Parser<ReaderType, WriterType, NowPlaying, ProcessorsType>
2024-06-15 16:38:37 -04:00
: public CustomParser<ReaderType, WriterType, ProcessorsType, NowPlaying, NowPlayingImpl> {};
2024-06-01 06:59:01 -04:00
template <class ReaderType, class WriterType, class ProcessorsType>
struct Parser<ReaderType, WriterType, Config, ProcessorsType>
2024-06-15 16:38:37 -04:00
: public CustomParser<ReaderType, WriterType, ProcessorsType, Config, ConfigImpl> {};
2024-06-14 01:41:59 -04:00
}