SimulationCaseFactory< CaseType > Class Template Reference
|
Developer Documentation
|
Factory class for registering and creating simulation cases. More...
#include <case_factory.hpp>
Public Types | |
| using | SimulationCreator = std::function< std::unique_ptr< CaseType >(const std::string, const MPI_Comm)> |
| Type definition for a function that creates a simulation case. | |
Static Public Member Functions | |
| static bool | register_simulation (const std::string name, SimulationCreator creator) |
| Registers a simulation case with a unique name. | |
| static std::unique_ptr< CaseType > | create_simulation (const std::string name, const std::string parameter_file, const MPI_Comm mpi_communicator) |
| Creates an instance of a registered simulation case. | |
Static Private Attributes | |
| static std::map< std::string, SimulationCreator > | creators |
| Stores registered simulation case creators. | |
Detailed Description
class SimulationCaseFactory< CaseType >
Factory class for registering and creating simulation cases.
This class provides a mechanism for dynamically registering and creating instances of simulation case classes based on a string identifier.
- Template Parameters
-
CaseType The base class type for simulation cases.
Member Typedef Documentation
◆ SimulationCreator
| using SimulationCaseFactory< CaseType >::SimulationCreator = std::function<std::unique_ptr<CaseType>(const std::string, const MPI_Comm)> |
Type definition for a function that creates a simulation case.
The function takes a parameter file and an MPI communicator as input and returns a unique pointer to an instance of the simulation case.
Member Function Documentation
◆ create_simulation()
|
inlinestatic |
Creates an instance of a registered simulation case.
- Parameters
-
name The unique identifier of the simulation case to create. parameter_file The parameter file used for initialization. mpi_communicator The MPI communicator for parallel execution.
- Returns
- A unique pointer to the created simulation case instance.
- Exceptions
-
Exception if the requested case is not registered.
This function retrieves the corresponding creator function from the factory and uses it to instantiate the requested simulation case.
◆ register_simulation()
|
inlinestatic |
Registers a simulation case with a unique name.
- Parameters
-
name The unique identifier for the simulation case. creator A function that creates an instance of the simulation case.
- Returns
- True if the registration was successful.
- Exceptions
-
Exception if a case with the same name is already registered.
This function ensures that each simulation case is registered only once.
Member Data Documentation
◆ creators
|
inlinestaticprivate |
Stores registered simulation case creators.
A static map that associates simulation case names with their corresponding creator functions.
The documentation for this class was generated from the following file:
- include/meltpooldg/core/case_factory.hpp
Generated by