1 #ifndef ABLATELIBRARY_RUNENVIRONMENT_HPP
2 #define ABLATELIBRARY_RUNENVIRONMENT_HPP
6 #include <parameters/mapParameters.hpp>
9 #include "parameters/parameters.hpp"
11 namespace ablate::environment {
15 inline static int DefaultGlobalArgc = 0;
18 inline static char** DefaultGlobalArgs =
nullptr;
21 inline static int* GlobalArgc = &DefaultGlobalArgc;
24 inline static char*** GlobalArgs = &DefaultGlobalArgs;
27 std::filesystem::path outputDirectory;
30 const std::string title;
36 static const inline std::regex OutputDirectoryVariable = std::regex(
"\\$OutputDirectory");
41 struct FinalizeFunction {
43 std::function<void()>
function;
49 inline static std::vector<FinalizeFunction> finalizeFunctions;
65 if (!runEnvironment) {
68 return *runEnvironment;
75 [[nodiscard]]
inline const std::filesystem::path&
GetOutputDirectory()
const {
return outputDirectory; }
89 static void Initialize(
int* argc,
char*** args);
102 static inline int* GetArgCount() {
return GlobalArgc; }
104 static inline char*** GetArgs() {
return GlobalArgs; }
121 Insert(
"directory", path.string());
130 Insert(
"tagDirectory", tag);
138 Insert(
"title", simulationTitle);
144 inline static std::unique_ptr<RunEnvironment> runEnvironment = std::unique_ptr<RunEnvironment>();
Definition: runEnvironment.hpp:114
Parameters & Title(std::string simulationTitle)
Definition: runEnvironment.hpp:137
Parameters & TagDirectory(bool tag)
Definition: runEnvironment.hpp:129
Parameters & OutputDirectory(const std::filesystem::path &path)
Definition: runEnvironment.hpp:120
Definition: runEnvironment.hpp:12
static std::string_view GetVersion()
Definition: runEnvironment.cpp:88
static void RegisterCleanUpFunction(const std::string &name, std::function< void()>)
Definition: runEnvironment.cpp:68
const std::filesystem::path & GetOutputDirectory() const
Definition: runEnvironment.hpp:75
void ExpandVariables(std::string &value) const
Definition: runEnvironment.cpp:86
static void Initialize(int *argc, char ***args)
Definition: runEnvironment.cpp:63
static void Finalize()
Definition: runEnvironment.cpp:77
Definition: mapParameters.hpp:12
void Insert(std::string key, T value)
Definition: mapParameters.hpp:69
Definition: parameters.hpp:15