11#ifndef CLOYSTERHPC_FUNCTIONS_H_
22#define CLOYSTERHPC_FUNCTIONS_H_
33
4- #include " services/log.h"
4+ #include < cloysterhpc/models/cluster.h>
5+ #include < cloysterhpc/services/log.h>
56#include < boost/process/child.hpp>
67#include < boost/process/pipe.hpp>
78#include < cloysterhpc/services/repos.h>
@@ -19,6 +20,9 @@ namespace cloyster {
1920extern bool dryRun;
2021
2122using OS = cloyster::models::OS;
23+
24+ void initClusterSingleton (std::unique_ptr<models::Cluster> cluster);
25+ models::Cluster& getClusterSingleton ();
2226std::shared_ptr<cloyster::services::BaseRunner> getRunner ();
2327std::shared_ptr<cloyster::services::repos::RepoManager> getRepoManager (
2428 const OS& osinfo);
@@ -222,6 +226,29 @@ std::filesystem::directory_iterator openDir(const Path& path)
222226 fmt::format (" Dry Run: Would open directory {}" , path.string ()));
223227}
224228
229+ /* *
230+ * @brief Converts enum to string.
231+ * @desc The case is the same used in the enum definition. Convert
232+ * it to lower before comparing.
233+ */
234+ template <typename T>
235+ requires std::is_enum_v<T>
236+ std::string enumToString (T enumValue)
237+ {
238+ return static_cast <std::string>(magic_enum::enum_name<T>(enumValue));
239+ }
240+
241+ /* *
242+ * @brief Converts a string to an enum if possible
243+ * @desc The comparison is made case insensitive
244+ */
245+ template <typename T>
246+ requires std::is_enum_v<T>
247+ std::optional<T> enumOfStringOpt (const std::string& str)
248+ {
249+ return magic_enum::enum_cast<T>(str, magic_enum::case_insensitive);
250+ }
251+
225252}
226253
227254#endif // CLOYSTERHPC_FUNCTIONS_H_
0 commit comments