Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
Interface.cpp
Go to the documentation of this file.
1#include "Interface.h"
2
3#include <stdexcept>
4
5#include "2HDMC.h"
6#include "SoftSusy.h"
7
9 switch(type) {
11 return std::make_shared<SoftsusyCalculator>();
13 return std::make_shared<TwoHDMCalculator>();
14 default:
15 throw std::invalid_argument("Invalid Calculator Type");
16 }
17}
18
19void GeneralCalculatorFactory::executeCommand(CalculatorType type, const std::string& commandName, const std::string& inputFilePath, const std::string& outputFilePath) {
20 using CommandFunction = std::function<void(const std::string&, const std::string&)>;
21 static std::unordered_map<std::string, CommandFunction> commonCommands = {
22 {"calculateSpectrum", [type](const std::string& input, const std::string& output) {
23 auto calculator = createCalculator(type);
24 calculator->calculateSpectrum(input, output);
25 }}
26 };
27
28 auto commandIterator = commonCommands.find(commandName);
29 if (commandIterator != commonCommands.end()) {
30 commandIterator->second(inputFilePath, outputFilePath);
31 } else {
32 throw std::invalid_argument("Calculator command '" + commandName + "' is not recognized.");
33 }
34}
Declares generic calculator interfaces and the general calculator factory.
CalculatorType
Definition Interface.h:33
@ TwoHDM
Use 2HDMC–based calculator.
@ Softsusy
Use SOFTSUSY–based calculator.
static void executeCommand(CalculatorType type, const std::string &commandName, const std::string &inputFilePath, const std::string &outputFilePath)
Executes a named command on a chosen calculator type.
Definition Interface.cpp:19
static std::shared_ptr< ICalculator > createCalculator(CalculatorType type)
Creates a concrete calculator for a given type.
Definition Interface.cpp:8