draconisplusplus/src/config/config.h

77 lines
2.1 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 <rfl.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-16 00:13:15 -04:00
explicit 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-16 00:13:15 -04:00
explicit 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:
2024-06-16 00:13:15 -04:00
/**
* @brief Creates a new Config instance.
*
* @param general The general section of the configuration.
* @param now_playing The now playing section of the configuration.
* @param weather The weather section of the configuration.
*/
2024-06-01 06:59:01 -04:00
Config(General general, NowPlaying now_playing, Weather weather);
2024-06-16 00:13:15 -04:00
/**
* @brief Gets the current (read-only) configuration.
*
* @return The current Config instance.
*/
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-16 00:13:15 -04:00
DEF_IMPL(General, std::string name)
DEF_IMPL(NowPlaying, std::optional<bool> enabled)
DEF_IMPL(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-16 00:13:15 -04:00
: 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-16 00:13:15 -04:00
: 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-16 00:13:15 -04:00
: CustomParser<ReaderType, WriterType, ProcessorsType, Config, ConfigImpl> {};
2024-06-14 01:41:59 -04:00
}