Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
MappingDatabaseProxy.cpp
Go to the documentation of this file.
2#include <stdexcept>
3
4std::shared_ptr<MappingDatabaseProxy> MappingDatabaseProxy::fromFactory(
5 const IMappingAdapterFactory& factory,
6 const std::string& instanceName,
7 const std::string& jsonFilePath,
8 std::shared_ptr<IParamMappingSource> loader
9) {
10 auto adapter = factory.create(instanceName, jsonFilePath, std::move(loader));
11 return std::make_shared<MappingDatabaseProxy>(std::move(adapter));
12}
13
14MappingDatabaseProxy::MappingDatabaseProxy(std::shared_ptr<IMappingDatabaseAdapter> adapter)
15 : adapter_(std::move(adapter)) {
16 if (!adapter_) throw std::runtime_error("MappingDatabaseProxy: adapter is null");
17}
18
19std::unordered_map<std::string, InterpretedParam>
21 return adapter_->getParams();
22}
23
24std::optional<InterpretedParam>
25MappingDatabaseProxy::getParam(const std::string& name) const {
26 return adapter_->getParam(name);
27}
28
30 return adapter_->instanceName();
31}
Declares a proxy implementation of IMappingDatabasePort.
Factory interface for building IMappingDatabaseAdapter instances.
virtual std::shared_ptr< IMappingDatabaseAdapter > create(const std::string &instanceName, const std::string &jsonFilePath, std::shared_ptr< IParamMappingSource > loader) const =0
Creates a mapping database adapter from an underlying JSON-like file.
static std::shared_ptr< MappingDatabaseProxy > fromFactory(const IMappingAdapterFactory &factory, const std::string &instanceName, const std::string &jsonFilePath, std::shared_ptr< IParamMappingSource > loader=nullptr)
Factory helper to create a proxy with a given adapter factory.
MappingDatabaseProxy(std::shared_ptr< IMappingDatabaseAdapter > adapter)
Constructs a new proxy from an existing adapter.
std::optional< InterpretedParam > getParam(const std::string &name) const override
Retrieves a parameter mapping by name.
std::unordered_map< std::string, InterpretedParam > getParams() const override
Returns all parameters stored in the database.
std::string instanceName() const override
Returns a logical name for this database instance.
Hash specialization for SymbolId<Tag>.
Definition BlockName.h:353