Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
MartyAdapter.cpp
Go to the documentation of this file.
1#include "MartyAdapter.h"
2
3#include <filesystem>
4#include <stdexcept>
5
6fs::path MartyAdapter::get_path(MartyPath path_name) {
8
9 switch (path_name) {
11 const auto& config = mm->getMemoryCache().config;
12 if (!config.mty_model_path.has_value()) {
13 throw std::logic_error("MARTY model path is not defined in HyperisoConfig::mty_model_path.");
14 }
15 return config.mty_model_path.value();
16 }
17
19 const fs::path path = mm->get_path(APIPath::ASSETS_ROOT)
20 / "input_files" / "marty_model" / "sm.h";
21 if (!fs::is_regular_file(path)) {
22 throw std::runtime_error(
23 "Packaged MARTY SM model header is missing: " + path.string()
24 );
25 }
26 return path;
27 }
28
30 return mm->get_path(APIPath::PARAM_MAPPING_DIR);
31
33 return mm->get_path(APIPath::PARAM_MAPPING_DIR) / "sm.json";
34
36 return mm->get_path(APIPath::TEMPLATE_DIR) / "MARTY";
37
39 return mm->get_path(APIPath::MARTY_TEMP_DIR);
40
42 auto optional_path = get_optional_path(path_name);
43 if (!optional_path.has_value()) {
44 throw std::logic_error("MARTY BSM mapping path is not defined in HyperisoConfig::mty_bsm_mapping_path.");
45 }
46 return optional_path.value();
47 }
48 }
49
50 throw std::logic_error("Unknown MartyPath.");
51}
52
53std::optional<fs::path> MartyAdapter::get_optional_path(MartyPath path_name) {
54 if (path_name != MartyPath::BSM_MAPPING_FILE) {
55 return get_path(path_name);
56 }
57
58 const auto& config = MemoryManager::GetInstance()->getMemoryCache().config;
59 return config.mty_bsm_mapping_path;
60}
61
65
67 const auto& config = MemoryManager::GetInstance()->getMemoryCache().config;
68
69 if (!config.mty_model_name.has_value()) {
70 throw std::logic_error("MARTY model name is not defined in HyperisoConfig::mty_model_name.");
71 }
72
73 return config.mty_model_name.value();
74}
@ TEMPLATE_DIR
Read-only directory containing generated-code templates.
@ MARTY_TEMP_DIR
Writable cache directory used for generated MARTY files.
@ PARAM_MAPPING_DIR
Read-only directory containing MARTY/Hyperiso parameter mappings.
@ ASSETS_ROOT
Root directory for HyperISO read-only assets.
Core-side adapter giving MARTY access to configuration and managed paths.
MartyPath
Enumerates MARTY-related filesystem resources.
@ BSM_MAPPING_FILE
@ PARAM_MAPPING_DIR
InternalFlag
Internal flags used for memory management status.
bool check_flag(InternalFlag flag) override
Checks the status of a specific internal flag.
fs::path get_path(MartyPath path_name) override
Retrieves a required MARTY-related path.
std::string get_marty_model_name() const
Retrieves the configured MARTY model name.
std::optional< fs::path > get_optional_path(MartyPath path_name) override
Retrieves an optional MARTY-related path.
const MemoryCache & getMemoryCache()
Retrieves the current memory cache.
static MemoryManager * GetInstance()
Retrieves the singleton instance of MemoryManager.
std::optional< fs::path > mty_bsm_mapping_path
Optional user-provided BSM mapping JSON.
Definition Config.h:47
std::map< InternalFlag, bool > flags
Internal status flags.
HyperisoConfig config
Config struct for various flags and runtime information.