Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
MemoryManager Class Reference

Singleton class responsible for initializing and managing memory, input files, and parameter blocks. More...

#include <MemoryManager.h>

Public Member Functions

void set_paths_provider (std::shared_ptr< IPathsProvider > paths_provider_)
 Replaces the filesystem path provider used by the manager.
 
fs::path get_path (APIPath path_name)
 Retrieves a public API path from the runtime cache or path provider.
 
void init (const std::string &lhaFile, HyperisoConfig config)
 Initializes the memory manager with the provided LHA file and configuration.
 
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.
 
void add_lha_prototypes (const std::vector< LhaPrototypeSpec > &prototypes)
 Registers several additional LHA block prototypes through the injected port.
 
void switch_lha (const std::string &lhaFile, HyperisoConfig config)
 Registers several additional LHA block prototypes.
 
void reload_user_input (HyperisoConfig config)
 Reloads user-specific input files.
 
void reload_user_input (const std::string &lhaFile, HyperisoConfig config)
 Reloads user-specific input files with a different LHA file.
 
void switch_model (Model model=Model::SM)
 Switches the model used for spectrum and parameters.
 
const MemoryCachegetMemoryCache ()
 Retrieves the current memory cache.
 
bool is_ready () const
 Returns whether MemoryManager has already completed init().
 
std::shared_ptr< BlockAccessorextract_blocks (std::unordered_set< BlockName > block_names)
 Extracts specific blocks from the cached input.
 
std::shared_ptr< BlockAccessorextract_block_accessor ()
 Extracts all blocks from the cached input.
 
std::shared_ptr< BlockAccessorclone_input_cache_deep () const
 Deep-clones the raw input cache as independent plain blocks.
 
const CorrelationRepositoryget_correlation_repository ()
 Retrieves the current correlation repository.
 
std::unordered_set< ParamIdget_all_source_parameters (const std::unordered_set< ParamId > &param_ids) const
 Computes all ultimate "source" parameters for a given set of parameter IDs.
 
 MemoryManager (const MemoryManager &)=delete
 
MemoryManageroperator= (const MemoryManager &)=delete
 
 MemoryManager (MemoryManager &&) noexcept=default
 
MemoryManageroperator= (MemoryManager &&) noexcept=default
 

Static Public Member Functions

static MemoryManagerGetInstance ()
 Retrieves the singleton instance of MemoryManager.
 
static MemoryManagerCreate (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.
 

Friends

class Parameters
 

Detailed Description

Singleton class responsible for initializing and managing memory, input files, and parameter blocks.

MemoryManager must be initialized first in a script or application that uses parameters.

Definition at line 67 of file MemoryManager.h.

Constructor & Destructor Documentation

◆ MemoryManager() [1/2]

MemoryManager::MemoryManager ( const MemoryManager )
delete

◆ MemoryManager() [2/2]

MemoryManager::MemoryManager ( MemoryManager &&  )
defaultnoexcept

Member Function Documentation

◆ add_lha_prototype()

void MemoryManager::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.

The prototype is stored by MemoryManager and also forwarded to the ParamBlockLoader when that concrete loader is available.

Definition at line 265 of file MemoryManager.cpp.

◆ add_lha_prototypes()

void MemoryManager::add_lha_prototypes ( const std::vector< LhaPrototypeSpec > &  prototypes)

Registers several additional LHA block prototypes through the injected port.

Definition at line 293 of file MemoryManager.cpp.

◆ clone_input_cache_deep()

std::shared_ptr< BlockAccessor > MemoryManager::clone_input_cache_deep ( ) const

Deep-clones the raw input cache as independent plain blocks.

This is used by per-thread runtime contexts so parameter mutations in one worker cannot affect the global cache or another worker.

Definition at line 54 of file MemoryManager.cpp.

◆ Create()

MemoryManager * 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 
)
static

Retrieves/creates the singleton instance of MemoryManager with injected dependencies.

Intended to be used by adapters/factories that wire loaders, spectrum calculator and path providers.

Definition at line 183 of file MemoryManager.cpp.

◆ extract_block_accessor()

std::shared_ptr< BlockAccessor > MemoryManager::extract_block_accessor ( )

Extracts all blocks from the cached input.

Returns
Shared pointer to the BlockAccessor containing all the blocks.

Definition at line 22 of file MemoryManager.cpp.

◆ extract_blocks()

std::shared_ptr< BlockAccessor > MemoryManager::extract_blocks ( std::unordered_set< BlockName block_names)

Extracts specific blocks from the cached input.

Parameters
block_namesSet of block names to extract.
Returns
Shared pointer to a new BlockAccessor containing the requested blocks.

Definition at line 18 of file MemoryManager.cpp.

◆ get_all_source_parameters()

std::unordered_set< ParamId > MemoryManager::get_all_source_parameters ( const std::unordered_set< ParamId > &  param_ids) const

Computes all ultimate "source" parameters for a given set of parameter IDs.

This walks through dependent parameters and dependent blocks to find leaf sources.

Parameters
param_idsSet of parameter IDs to analyze.
Returns
Set of source ParamId.

Definition at line 396 of file MemoryManager.cpp.

◆ get_correlation_repository()

const CorrelationRepository & MemoryManager::get_correlation_repository ( )

Retrieves the current correlation repository.

Returns
A const reference to the CorrelationRepository.

Definition at line 61 of file MemoryManager.cpp.

◆ get_path()

fs::path MemoryManager::get_path ( APIPath  path_name)

Retrieves a public API path from the runtime cache or path provider.

LHA_PATH comes from the current MemoryCache. All other paths are delegated to the active IPathsProvider.

Parameters
path_namePublic path identifier.
Returns
The corresponding filesystem path.

Definition at line 211 of file MemoryManager.cpp.

◆ GetInstance()

MemoryManager * MemoryManager::GetInstance ( )
static

Retrieves the singleton instance of MemoryManager.

Returns
Pointer to MemoryManager instance.

Definition at line 157 of file MemoryManager.cpp.

◆ getMemoryCache()

const MemoryCache & MemoryManager::getMemoryCache ( )
inline

Retrieves the current memory cache.

Returns
A const reference to the internal MemoryCache.

Definition at line 276 of file MemoryManager.h.

◆ init()

void MemoryManager::init ( const std::string &  lhaFile,
HyperisoConfig  config 
)

Initializes the memory manager with the provided LHA file and configuration.

Must be called before using any Parameters instances.

Parameters
lhaFilePath to the input LHA file.
configConfiguration settings to use.

Definition at line 306 of file MemoryManager.cpp.

◆ is_ready()

bool MemoryManager::is_ready ( ) const
inline

Returns whether MemoryManager has already completed init().

Definition at line 281 of file MemoryManager.h.

◆ operator=() [1/2]

MemoryManager & MemoryManager::operator= ( const MemoryManager )
delete

◆ operator=() [2/2]

MemoryManager & MemoryManager::operator= ( MemoryManager &&  )
defaultnoexcept

◆ reload_user_input() [1/2]

void MemoryManager::reload_user_input ( const std::string &  lhaFile,
HyperisoConfig  config 
)

Reloads user-specific input files with a different LHA file.

Parameters
lhaFilePath to the LHA file.
configNew configuration to apply.

Definition at line 356 of file MemoryManager.cpp.

◆ reload_user_input() [2/2]

void MemoryManager::reload_user_input ( HyperisoConfig  config)

Reloads user-specific input files.

Useful for reapplying user customizations without changing the LHA file.

Parameters
configNew configuration to apply.

Definition at line 352 of file MemoryManager.cpp.

◆ set_paths_provider()

void MemoryManager::set_paths_provider ( std::shared_ptr< IPathsProvider paths_provider_)

Replaces the filesystem path provider used by the manager.

Intended for pre-init customization through HyperisoMaster. If called after init(), it only affects future reload/switch operations that read paths again.

Parameters
paths_provider_New provider to use for all IPathsProvider-backed paths.

Definition at line 198 of file MemoryManager.cpp.

◆ switch_lha()

void MemoryManager::switch_lha ( const std::string &  lhaFile,
HyperisoConfig  config 
)

Registers several additional LHA block prototypes.

Switches to a different LHA file, reloading associated parameters and spectrum.

Parameters
lhaFilePath to the new LHA file.
configNew configuration to apply.

Definition at line 339 of file MemoryManager.cpp.

◆ switch_model()

void MemoryManager::switch_model ( Model  model = Model::SM)

Switches the model used for spectrum and parameters.

Must be compatible with the loaded LHA file.

Parameters
modelThe new model to switch to (default is SM).

Definition at line 389 of file MemoryManager.cpp.

Friends And Related Symbol Documentation

◆ Parameters

friend class Parameters
friend

Definition at line 327 of file MemoryManager.h.


The documentation for this class was generated from the following files: