preCICE v3.2.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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::io {
10
19public:
27
29 explicit TXTTableWriter(const std::string &filename);
30
38 void addData(
39 const std::string &name,
40 DataType type);
41
47 void writeData(
48 const std::string &name,
49 int value);
50
56 void writeData(
57 const std::string &name,
58 double value);
59
65 void writeData(
66 const std::string &name,
67 const Eigen::Vector2d &value);
68
69 void writeData(
70 const std::string &name,
71 const Eigen::Vector3d &value);
72
74 void close();
75
77 void reset();
78
79private:
81 struct Data {
82
84
86
87 bool operator==(const Data &data) const
88 {
89 return name == data.name;
90 }
91 };
92
93 logging::Logger _log{"io::TXTTableWriter"};
94
96
97 std::vector<Data>::const_iterator _writeIterator;
98
100};
101
102} // namespace precice::io
103
104// Required in order to print the vector types via the fmt interface
105template <>
106struct fmt::formatter<precice::io::TXTTableWriter::DataType> : formatter<string_view> {
107 // parse is inherited from formatter<string_view>.
108
109 auto format(precice::io::TXTTableWriter::DataType c, format_context &ctx) const;
110};
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:17
provides Import and Export of the coupling mesh and data.
Main namespace of the precice library.
Represents one data entry to be written.
bool operator==(const Data &data) const