1#ifndef HYPERISO_MEMORY_MANAGER_H
2#define HYPERISO_MEMORY_MANAGER_H
4#include <unordered_map>
71 std::shared_ptr<BlockAccessor> input_cache;
74 std::shared_ptr<ISpectrumCalculator> sc;
75 std::shared_ptr<IDataLoader<BlockAccessor>> dl_ba;
76 std::shared_ptr<IDataLoader<CorrelationMatrixPair<ParamId>>> dl_cmp_p;
77 std::shared_ptr<IDataLoader<CorrelationMatrixPair<ExperimentObs>>> dl_cmp_o;
78 std::shared_ptr<IPathsProvider> paths_provider;
79 std::shared_ptr<ILhaPrototypeRegistry> lha_prototype_registry;
92 std::shared_ptr<ISpectrumCalculator> spectrum_c,
93 std::shared_ptr<IPathsProvider> paths_provider_,
94 std::shared_ptr<ILhaPrototypeRegistry> lha_prototype_registry_);
100 void check_if_ready();
107 void read_default_input();
114 void read_user_input();
122 void read_lha_input(
const std::string& lhaFile,
const HyperisoConfig& config);
133 fs::path format_lha_path(
const std::string& path);
144 fs::path calculate_spectrum(fs::path input_lha_path,
const HyperisoConfig& config);
160 void save_input_cache();
178 std::shared_ptr<ISpectrumCalculator> spectrum_c,
179 std::shared_ptr<IPathsProvider> paths_provider,
180 std::shared_ptr<ILhaPrototypeRegistry> lha_prototype_registry=
nullptr);
226 bool globalScale=
false);
289 std::shared_ptr<BlockAccessor>
extract_blocks(std::unordered_set<BlockName> block_names);
Alias-aware façade for accessing and manipulating multiple parameter blocks.
Concrete memento for BlockAccessor snapshots.
Defines a generic interface for data loading operations.
APIPath
Enumerates the filesystem paths exposed through the public API.
Declares the interface for spectrum calculators.
InternalFlag
Internal flags used for memory management status.
Block identifier with alias support.
Manages correlations between parameters and experiment-scoped observables.
Stack-based implementation of IDBMemento for BlockAccessor.
Abstract interface for loading data into an object.
Singleton class responsible for initializing and managing memory, input files, and parameter blocks.
std::shared_ptr< BlockAccessor > extract_block_accessor()
Extracts all blocks from the cached input.
const MemoryCache & getMemoryCache()
Retrieves the current memory cache.
std::shared_ptr< BlockAccessor > clone_input_cache_deep() const
Deep-clones the raw input cache as independent plain blocks.
void reload_user_input(HyperisoConfig config)
Reloads user-specific input files.
void set_paths_provider(std::shared_ptr< IPathsProvider > paths_provider_)
Replaces the filesystem path provider used by the manager.
void switch_lha(const std::string &lhaFile, HyperisoConfig config)
Registers several additional LHA block prototypes.
std::unordered_set< ParamId > get_all_source_parameters(const std::unordered_set< ParamId > ¶m_ids) const
Computes all ultimate "source" parameters for a given set of parameter IDs.
MemoryManager(const MemoryManager &)=delete
MemoryManager & operator=(const MemoryManager &)=delete
void init(const std::string &lhaFile, HyperisoConfig config)
Initializes the memory manager with the provided LHA file and configuration.
static MemoryManager * GetInstance()
Retrieves the singleton instance of MemoryManager.
static MemoryManager * Create(std::shared_ptr< IDataLoader< BlockAccessor > > loader, std::shared_ptr< IDataLoader< CorrelationMatrixPair< ParamId > > > param_corr, std::shared_ptr< IDataLoader< CorrelationMatrixPair< ExperimentObs > > > obs_corr, std::shared_ptr< ISpectrumCalculator > spectrum_c, std::shared_ptr< IPathsProvider > paths_provider, std::shared_ptr< ILhaPrototypeRegistry > lha_prototype_registry=nullptr)
Retrieves/creates the singleton instance of MemoryManager with injected dependencies.
const CorrelationRepository & get_correlation_repository()
Retrieves the current correlation repository.
void switch_model(Model model=Model::SM)
Switches the model used for spectrum and parameters.
fs::path get_path(APIPath path_name)
Retrieves a public API path from the runtime cache or path provider.
std::shared_ptr< BlockAccessor > extract_blocks(std::unordered_set< BlockName > block_names)
Extracts specific blocks from the cached input.
MemoryManager(MemoryManager &&) noexcept=default
void add_lha_prototypes(const std::vector< LhaPrototypeSpec > &prototypes)
Registers several additional LHA block prototypes through the injected port.
void add_lha_prototype(BlockName blockName, size_t itemCount=2, size_t valueIdx=1, int scaleIdx=-1, int rgIdx=-1, int binIdx=-1, bool globalScale=false)
Registers an additional LHA block prototype before LHA parsing.
bool is_ready() const
Returns whether MemoryManager has already completed init().
Block-based parameter repository for one ParameterType namespace.
double f(double x)
Wilson special function f depending on x.
Stores a pair of correlation matrices (statistical and systematic) for a given key type.
Configuration object controlling model, input flags and optional MARTY resources.
Stores memory cache details for parameter management and runtime state.
std::vector< ParameterType > parameter_types
List of parameter types currently managed.
bool is_ready
Indicates if the memory manager is initialized and ready.
std::thread::id thread_id
Thread ID associated with the current cache usage.
std::map< InternalFlag, bool > flags
Internal status flags.
HyperisoConfig config
Config struct for various flags and runtime information.
fs::path lha_path
Path to the currently loaded LHA file.
RAII guard to toggle the "ready" flag while performing unsafe operations.