Loading...
Searching...
No Matches
writer.hpp
Go to the documentation of this file.
1#pragma once
2
3/**
4 * VolumetricFieldWriter — abstract writer for one volumetric file format.
5 *
6 * Every format Q3 can put a real-space field into implements this: Gaussian
7 * cube, XCrySDen XSF, and any a build-time add-on registers. The caller builds
8 * a VolumetricField once and
9 * asks the factory for a writer by name, so adding a format never touches
10 * the code that produced the field.
11 */
12
13#include <string>
14
16
17namespace q3 {
18
20 public:
21 virtual ~VolumetricFieldWriter() = default;
22
23 /// Write `field` to `path`, throwing std::runtime_error if it cannot be written.
24 virtual void write(const std::string& path, const VolumetricField& field) const = 0;
25
26 /**
27 * What a file of this format is conventionally called, given a run's
28 * prefix and the field's name. Cube and XSF take a suffix; a format whose
29 * file has a fixed name says so by returning that name unchanged.
30 */
31 [[nodiscard]] virtual std::string default_file_name(const std::string& stem) const = 0;
32};
33
34} // namespace q3
virtual ~VolumetricFieldWriter()=default
virtual std::string default_file_name(const std::string &stem) const =0
virtual void write(const std::string &path, const VolumetricField &field) const =0
Write field to path, throwing std::runtime_error if it cannot be written.