Loading...
Searching...
No Matches
factory.hpp
Go to the documentation of this file.
1#pragma once
2
3/**
4 * Factory for MeanFieldExporter implementations.
5 *
6 * Resolves the input's export format name (InputData::mean_field_export /
7 * YAML `control.mean_field_export`) to a concrete exporter, mirroring
8 * create_isolated_system_correction_calculator(). "none" (or empty) resolves
9 * to NullMeanFieldExporter so call sites need no branching; unknown names
10 * fail loudly rather than silently skipping the export the user asked for
11 * (the YAML parser already validates the value, so a throw here means a
12 * programmatic caller bypassed parsing). Adding a format = one new class
13 * implementing MeanFieldExporter + one case here.
14 */
15
16#include <memory>
17#include <stdexcept>
18#include <string>
19
23
24namespace q3 {
25
26[[nodiscard]] inline std::unique_ptr<MeanFieldExporter>
27create_mean_field_exporter(const std::string& mean_field_export) {
28 if (mean_field_export.empty() || mean_field_export == "none") {
29 return std::make_unique<NullMeanFieldExporter>();
30 }
31 if (mean_field_export == "berkeleygw") {
32 return std::make_unique<BerkeleyGWExporter>();
33 }
34 throw std::runtime_error("Unknown mean_field_export '" + mean_field_export +
35 "'. Supported: none, berkeleygw");
36}
37
38} // namespace q3
std::unique_ptr< MeanFieldExporter > create_mean_field_exporter(const std::string &mean_field_export)
Definition factory.hpp:27