netxsimdg
Loading...
Searching...
No Matches
ConfigOutput.hpp
Go to the documentation of this file.
1
8#ifndef CONFIGOUTPUT_HPP
9#define CONFIGOUTPUT_HPP
10
12
15#include "include/Time.hpp"
16
17#include <set>
18
19namespace Nextsim {
20
25class ConfigOutput : public IDiagnosticOutput, public Configured<ConfigOutput> {
26public:
28 virtual ~ConfigOutput() = default;
29
30 enum {
31 PERIOD_KEY,
32 START_KEY,
33 FIELDNAMES_KEY,
34 };
35
36 // IDiagnosticOutput overrides
37 void setFilenamePrefix(const std::string& filePrefix) override { m_filePrefix = filePrefix; }
38
39 void outputState(const ModelMetadata& meta) override;
40
41 // ModelComponent overrides
42 inline std::string getName() const override { return "ConfigOutput"; };
43 inline void setData(const ModelState::DataMap&) override {};
44 inline ModelState getState() const override { return ModelState(); };
45 inline ModelState getState(const OutputLevel&) const override { return ModelState(); };
46
47 // Configured overrides
48 void configure() override;
49 ModelState getStateRecursive(const OutputSpec& os) const override;
50
51private:
52 std::string m_filePrefix;
53 Duration outputPeriod;
54 bool firstOutput = true;
55 bool everyTS = false;
56 bool outputAllTheFields = false;
57 TimePoint lastOutput;
58 std::set<std::string> fieldsForOutput;
59 std::string currentFileName;
60 std::set<ModelComponent::SharedArray> sharedArraysForOutput;
61 std::set<ModelComponent::ProtectedArray> protectedArraysForOutput;
62
63 static const std::string all;
64 static const std::string defaultLastOutput;
65};
66
67} /* namespace Nextsim */
68
69#endif /* CONFIGOUTPUT_HPP */
ModelState getStateRecursive(const OutputSpec &os) const override
Returns the state of the ModelComponent and any ModelComponents it depends on.
ModelState getState() const override
Returns a ModelState from this component.
void outputState(const ModelMetadata &meta) override
Outputs the passed ModelState.
void setFilenamePrefix(const std::string &filePrefix) override
Sets the output file name.
ModelState getState(const OutputLevel &) const override
Returns a ModelState from this component at a specified level.
std::string getName() const override
Returns the name of the component.
void setData(const ModelState::DataMap &) override
Set the initial data of the component from the passed ModelState.
void configure() override
The configuration function.