Version: SMASH-3.1
smash::ExperimentBase Class Referenceabstract

#include <experiment.h>

Non-template interface to Experiment<Modus>.

This class allows to call into the public interface of Experiment<Modus> without the need to know the specific Modus. The interface is meant for main() to set up the experiment and then run takes over.

Definition at line 99 of file experiment.h.

Inheritance diagram for smash::ExperimentBase:
smash::Experiment< Modus >

Classes

struct  InvalidModusRequest
 Exception class that is thrown if an invalid modus is requested from the Experiment factory. More...
 
struct  NonExistingOutputPathRequest
 Exception class that is thrown if the requested output path in the Experiment factory is not existing. More...
 

Public Member Functions

 ExperimentBase ()=default
 
virtual ~ExperimentBase ()=default
 The virtual destructor avoids undefined behavior when destroying derived objects. More...
 
virtual void run ()=0
 Runs the experiment. More...
 

Static Public Member Functions

static std::unique_ptr< ExperimentBasecreate (Configuration &config, const std::filesystem::path &output_path)
 Factory method that creates and initializes a new Experiment<Modus>. More...
 

Constructor & Destructor Documentation

◆ ExperimentBase()

smash::ExperimentBase::ExperimentBase ( )
default

◆ ~ExperimentBase()

virtual smash::ExperimentBase::~ExperimentBase ( )
virtualdefault

The virtual destructor avoids undefined behavior when destroying derived objects.

Member Function Documentation

◆ create()

ExperimentPtr smash::ExperimentBase::create ( Configuration config,
const std::filesystem::path &  output_path 
)
static

Factory method that creates and initializes a new Experiment<Modus>.

This function creates a new Experiment object. The Modus template argument is determined by the config argument.

Parameters
[in,out]configThe configuration object that sets all initial conditions of the experiment.
[in]output_pathThe directory where the output files are written.
Returns
An owning pointer to the Experiment object, using the ExperimentBase interface.
Exceptions
InvalidModusRequestThis exception is thrown if the Modus string in the config object does not contain a valid string.

Most of the Configuration values are read starting from this function. The configuration itself is documented in General

Definition at line 22 of file experiment.cc.

23  {
24  if (!std::filesystem::exists(output_path)) {
25  throw NonExistingOutputPathRequest("The requested output path (" +
26  output_path.string() +
27  ") does not exist.");
28  }
30 
31  const std::string modus_chooser = config.read({"General", "Modus"});
32  logg[LExperiment].debug() << "Modus for this calculation: " << modus_chooser;
33 
34  if (modus_chooser == "Box") {
35  return std::make_unique<Experiment<BoxModus>>(config, output_path);
36  } else if (modus_chooser == "List") {
37  return std::make_unique<Experiment<ListModus>>(config, output_path);
38  } else if (modus_chooser == "ListBox") {
39  return std::make_unique<Experiment<ListBoxModus>>(config, output_path);
40  } else if (modus_chooser == "Collider") {
41  return std::make_unique<Experiment<ColliderModus>>(config, output_path);
42  } else if (modus_chooser == "Sphere") {
43  return std::make_unique<Experiment<SphereModus>>(config, output_path);
44  } else {
45  throw InvalidModusRequest("Invalid Modus (" + modus_chooser +
46  ") requested from ExperimentBase::create.");
47  }
48 }
#define SMASH_SOURCE_LOCATION
Hackery that is required to output the location in the source code where the log statement occurs.
Definition: logging.h:153
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
Definition: logging.cc:39
static constexpr int LExperiment

◆ run()

virtual void smash::ExperimentBase::run ( )
pure virtual

Runs the experiment.

The constructor does the setup of the experiment. The run function executes the complete experiment.

Implemented in smash::Experiment< Modus >.


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