diff --git a/meson.build b/meson.build index 4791131..776f868 100644 --- a/meson.build +++ b/meson.build @@ -23,6 +23,7 @@ if host_machine.system() == 'darwin' add_project_arguments( objcpp.get_supported_arguments([ '-Wno-c++20-compat', + '-Wno-c++20-extensions', '-Wno-c++98-compat', '-Wno-c++98-compat-pedantic', '-Wno-disabled-macro-expansion', @@ -39,6 +40,7 @@ endif add_project_arguments( cpp.get_supported_arguments([ '-Wno-c++20-compat', + '-Wno-c++20-extensions', '-Wno-c++98-compat', '-Wno-c++98-compat-pedantic', '-Wno-disabled-macro-expansion', diff --git a/src/config/weather.cpp b/src/config/weather.cpp index bfb70cd..86ecdda 100644 --- a/src/config/weather.cpp +++ b/src/config/weather.cpp @@ -7,6 +7,8 @@ #include "util/result.h" +using WeatherOutput = Weather::WeatherOutput; + DEFINE_GETTER(Weather, const Weather::Location, Location) DEFINE_GETTER(Weather, const std::string, ApiKey) DEFINE_GETTER(Weather, const std::string, Units) @@ -24,8 +26,6 @@ fn WeatherImpl::from_class(const Weather& weather) noexcept -> WeatherImpl { fn WeatherImpl::to_class() const -> Weather { return { location, api_key, units }; } -using WeatherOutput = Weather::WeatherOutput; - // Function to read cache from file fn ReadCacheFromFile() -> Result { std::ifstream ifs("/tmp/weather_cache.json"); diff --git a/src/config/weather.h b/src/config/weather.h index 4987507..60cfac3 100644 --- a/src/config/weather.h +++ b/src/config/weather.h @@ -80,18 +80,17 @@ class Weather { using Location = std::variant; - private: - Location m_Location; - std::string m_ApiKey; - std::string m_Units; - - public: Weather(Location location, std::string api_key, std::string units); [[nodiscard]] fn getWeatherInfo() const -> WeatherOutput; [[nodiscard]] fn getLocation() const -> const Location; [[nodiscard]] fn getApiKey() const -> const std::string; [[nodiscard]] fn getUnits() const -> const std::string; + + private: + Location m_Location; + std::string m_ApiKey; + std::string m_Units; }; DEF_IMPL(Weather, Weather::Location location; std::string api_key; std::string units) diff --git a/src/main.cpp b/src/main.cpp index eca51f9..a477347 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "config/config.h" #include "os/os.h" @@ -50,26 +51,36 @@ fn main() -> int { using WeatherOutput = Weather::WeatherOutput; const Config& config = Config::getInstance(); - WeatherOutput json = config.getWeather().getWeatherInfo(); - const long temp = std::lround(json.main.temp); - const string townName = json.name; + auto weatherFuture = + std::async(std::launch::async, [&config]() { return config.getWeather().getWeatherInfo(); }); - const char* version = GetOSVersion(); - const string name = config.getGeneral().getName(); - const bool nowPlayingEnabled = config.getNowPlaying().getEnabled(); + auto osVersionFuture = std::async(std::launch::async, GetOSVersion); + auto nowPlayingEnabledFuture = + std::async(std::launch::async, [&config]() { return config.getNowPlaying().getEnabled(); }); + + auto dateFuture = std::async(std::launch::async, GetDate); + auto memInfoFuture = std::async(std::launch::async, GetMemInfo); + + WeatherOutput json = weatherFuture.get(); + const long temp = std::lround(json.main.temp); + const std::string townName = json.name; + + const char* version = osVersionFuture.get(); + const std::string name = config.getGeneral().getName(); + const bool nowPlayingEnabled = nowPlayingEnabledFuture.get(); fmt::println("Hello {}!", name); - fmt::println("Today is: {}", GetDate()); + fmt::println("Today is: {}", dateFuture.get()); fmt::println("It is {}°F in {}", temp, townName); - fmt::println("Installed RAM: {:.2f}", BytesToGiB { GetMemInfo() }); + fmt::println("Installed RAM: {:.2f} GiB", BytesToGiB(memInfoFuture.get())); fmt::println("{}", version); - if (nowPlayingEnabled) + if (nowPlayingEnabled) { fmt::println("{}", GetNowPlaying()); + } delete[] version; - delete &config; return 0; }