preCICE v3.1.2
Loading...
Searching...
No Matches
TXTTableWriter.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Eigen/Core>
4#include <fstream>
5#include <string>
6#include <vector>
7#include "logging/Logger.hpp"
8
9namespace precice {
10namespace io {
11
20public:
28
30 explicit TXTTableWriter(const std::string &filename);
31
39 void addData(
40 const std::string &name,
41 DataType type);
42
48 void writeData(
49 const std::string &name,
50 int value);
51
57 void writeData(
58 const std::string &name,
59 double value);
60
66 void writeData(
67 const std::string & name,
68 const Eigen::Vector2d &value);
69
70 void writeData(
71 const std::string & name,
72 const Eigen::Vector3d &value);
73
75 void close();
76
78 void reset();
79
80private:
82 struct Data {
83
85
87
88 bool operator==(const Data &data) const
89 {
90 return name == data.name;
91 }
92 };
93
94 logging::Logger _log{"io::TXTTableWriter"};
95
97
98 std::vector<Data>::const_iterator _writeIterator;
99
101};
102
103} // namespace io
104} // namespace precice
105//Required in order to print the vector types via the fmt interface
106template <>
107struct fmt::formatter<precice::io::TXTTableWriter::DataType> : formatter<string_view> {
108 // parse is inherited from formatter<string_view>.
109
110 auto format(precice::io::TXTTableWriter::DataType c, format_context &ctx) const;
111};
std::string name
File writer for table-data in text-format.
void close()
Closes the file, is automatically called on destruction.
DataType
Constants defining possible data types to be written.
std::vector< Data >::const_iterator _writeIterator
void addData(const std::string &name, DataType type)
Adds a data entry to the table.
TXTTableWriter(const std::string &filename)
Constructor, opens file.
void reset()
Resets the table information.
void writeData(const std::string &name, int value)
Writes a integral scalar data value associated to the entry name.
This class provides a lightweight logger.
Definition Logger.hpp:16
Main namespace of the precice library.
Represents one data entry to be written.
bool operator==(const Data &data) const