yaml_export.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Software License Agreement
4  *
5  * Copyright (c) 2020,
6  * TU Dortmund - Institute of Control Theory and Systems Engineering.
7  * All rights reserved.
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  *
22  * Authors: Christoph Rösmann
23  *********************************************************************/
24 
25 #ifndef SRC_CORE_INCLUDE_CORBO_CORE_YAML_EXPORT_H_
26 #define SRC_CORE_INCLUDE_CORBO_CORE_YAML_EXPORT_H_
27 
29 #include <yaml-cpp/yaml.h>
30 
31 #include <fstream>
32 #include <memory>
33 
34 namespace corbo {
35 
44 class YamlExporter : public DataExporterInterface
45 {
46  public:
47  using Ptr = std::shared_ptr<YamlExporter>;
48 
49  YamlExporter();
50 
51  DataExporterInterface::Ptr getInstance() const override { return std::make_shared<YamlExporter>(); }
52 
53  std::string getFormatName() const override { return "Yaml"; }
54  std::string getFileSuffix() const override { return ".yaml"; }
55 
56  bool isSupportingSignalGroup() const override { return true; }
57  bool isSupportingTimeSeriesSignal() const override { return true; }
58  bool isSupportingTimeSeries() const override { return true; }
59  bool isSupportingTimeSeriesSequenceSignal() const override { return true; }
60  bool isSupportingIndexedValuesSignal() const override { return true; }
61  bool isSupportingIndexedValuesSetSignal() const override { return true; }
62  bool isSupportingMatrixSignal() const override { return true; }
63  bool isSupportingMatrixSetSignal() const override { return true; }
64 
65  bool exportSignalGroup(const std::string& filename, const CommonSignalTarget::SignalGroup& signal_group) override;
66  bool exportTimeSeriesSignal(const std::string& filename, const TimeSeriesSignal& signal) override;
67  bool exportTimeSeries(const std::string& filename, const TimeSeries& time_series) override;
68  bool exportTimeSeriesSequenceSignal(const std::string& filename, const TimeSeriesSequenceSignal& signal) override;
69  bool exportIndexedValuesSignal(const std::string& filename, const IndexedValuesSignal& signal) override;
70  bool exportIndexedValuesSetSignal(const std::string& filename, const IndexedValuesSetSignal& signal) override;
71  bool exportMatrixSignal(const std::string& filename, const MatrixSignal& signal) override;
72  bool exportMatrixSetSignal(const std::string& filename, const MatrixSetSignal& signal) override;
73 
74  private:
75  void emitSignalGroup(const CommonSignalTarget::SignalGroup& signal_group, YAML::Emitter& emitter, bool wrap_in_map = true);
76  void emitTimeSeries(const TimeSeries& time_series, YAML::Emitter& emitter, bool wrap_in_map = true);
77  void emitTimeSeries(const TimeSeriesSignal& signal, YAML::Emitter& emitter, bool wrap_in_map = true);
78  void emitTimeSeriesSequence(const TimeSeriesSequenceSignal& signal, YAML::Emitter& emitter, bool wrap_in_map = true);
79  void emitIndexedValues(const IndexedValuesSignal& signal, YAML::Emitter& emitter, bool wrap_in_map = true);
80  void emitIndexedValuesSet(const IndexedValuesSetSignal& signal, YAML::Emitter& emitter, bool wrap_in_map = true);
81  void emitMatrix(const MatrixSignal& signal, YAML::Emitter& emitter, bool wrap_in_map = true);
82  void emitMatrixSet(const MatrixSetSignal& signal, YAML::Emitter& emitter, bool wrap_in_map = true);
83 
84  void emitHeader(const SignalHeader& header, YAML::Emitter& emitter);
85 
86  bool write_file(const YAML::Emitter& emitter, const std::string& filename);
87 };
89 
90 } // namespace corbo
91 
92 #endif // SRC_CORE_INCLUDE_CORBO_CORE_YAML_EXPORT_H_
corbo::YamlExporter::YamlExporter
YamlExporter()
corbo::YamlExporter::exportTimeSeriesSequenceSignal
bool exportTimeSeriesSequenceSignal(const std::string &filename, const TimeSeriesSequenceSignal &signal) override
corbo::IndexedValuesSignal
Signal containing values indexed by a single integer.
Definition: signals.h:412
data_exporter_interface.h
corbo::YamlExporter::isSupportingMatrixSetSignal
bool isSupportingMatrixSetSignal() const override
Definition: yaml_export.h:107
corbo::YamlExporter::emitMatrixSet
void emitMatrixSet(const MatrixSetSignal &signal, YAML::Emitter &emitter, bool wrap_in_map=true)
corbo::YamlExporter::exportTimeSeries
bool exportTimeSeries(const std::string &filename, const TimeSeries &time_series) override
corbo
Definition: communication/include/corbo-communication/utilities.h:37
corbo::YamlExporter::emitIndexedValues
void emitIndexedValues(const IndexedValuesSignal &signal, YAML::Emitter &emitter, bool wrap_in_map=true)
corbo::YamlExporter::emitMatrix
void emitMatrix(const MatrixSignal &signal, YAML::Emitter &emitter, bool wrap_in_map=true)
corbo::YamlExporter::getInstance
DataExporterInterface::Ptr getInstance() const override
Return a newly created shared instance of the implemented class.
Definition: yaml_export.h:95
corbo::YamlExporter::isSupportingMatrixSignal
bool isSupportingMatrixSignal() const override
Definition: yaml_export.h:106
corbo::YamlExporter::emitTimeSeries
void emitTimeSeries(const TimeSeries &time_series, YAML::Emitter &emitter, bool wrap_in_map=true)
corbo::YamlExporter::Ptr
std::shared_ptr< YamlExporter > Ptr
Definition: yaml_export.h:91
corbo::TimeSeriesSignal
Time Series signal (trajectory resp. sequence of values w.r.t. time)
Definition: signals.h:266
corbo::YamlExporter::getFileSuffix
std::string getFileSuffix() const override
Definition: yaml_export.h:98
corbo::YamlExporter::exportTimeSeriesSignal
bool exportTimeSeriesSignal(const std::string &filename, const TimeSeriesSignal &signal) override
corbo::YamlExporter::emitIndexedValuesSet
void emitIndexedValuesSet(const IndexedValuesSetSignal &signal, YAML::Emitter &emitter, bool wrap_in_map=true)
corbo::YamlExporter::emitTimeSeriesSequence
void emitTimeSeriesSequence(const TimeSeriesSequenceSignal &signal, YAML::Emitter &emitter, bool wrap_in_map=true)
corbo::YamlExporter::isSupportingTimeSeries
bool isSupportingTimeSeries() const override
Definition: yaml_export.h:102
relicense.filename
filename
Definition: relicense.py:57
corbo::DataExporterInterface::Ptr
std::shared_ptr< DataExporterInterface > Ptr
Definition: data_exporter_interface.h:92
corbo::YamlExporter::getFormatName
std::string getFormatName() const override
Definition: yaml_export.h:97
corbo::FACTORY_REGISTER_DATA_EXPORTER
FACTORY_REGISTER_DATA_EXPORTER(TsvExporter)
corbo::YamlExporter
Export yaml files.
Definition: yaml_export.h:66
corbo::IndexedValuesSetSignal
Signal containing values indexed by an integer (int to double[] map)
Definition: signals.h:496
corbo::MatrixSetSignal
Signal containing a set of matrices.
Definition: signals.h:629
corbo::YamlExporter::exportIndexedValuesSetSignal
bool exportIndexedValuesSetSignal(const std::string &filename, const IndexedValuesSetSignal &signal) override
corbo::TimeSeries
Time Series (trajectory resp. sequence of values w.r.t. time)
Definition: time_series.h:76
corbo::YamlExporter::exportMatrixSignal
bool exportMatrixSignal(const std::string &filename, const MatrixSignal &signal) override
corbo::YamlExporter::isSupportingTimeSeriesSignal
bool isSupportingTimeSeriesSignal() const override
Definition: yaml_export.h:101
corbo::SignalHeader
Signal header.
Definition: signals.h:97
corbo::YamlExporter::isSupportingSignalGroup
bool isSupportingSignalGroup() const override
Definition: yaml_export.h:100
corbo::YamlExporter::exportMatrixSetSignal
bool exportMatrixSetSignal(const std::string &filename, const MatrixSetSignal &signal) override
corbo::YamlExporter::exportSignalGroup
bool exportSignalGroup(const std::string &filename, const CommonSignalTarget::SignalGroup &signal_group) override
corbo::TimeSeriesSequenceSignal
Signal for a sequence of time series objects.
Definition: signals.h:355
corbo::YamlExporter::isSupportingIndexedValuesSetSignal
bool isSupportingIndexedValuesSetSignal() const override
Definition: yaml_export.h:105
corbo::YamlExporter::exportIndexedValuesSignal
bool exportIndexedValuesSignal(const std::string &filename, const IndexedValuesSignal &signal) override
corbo::YamlExporter::isSupportingTimeSeriesSequenceSignal
bool isSupportingTimeSeriesSequenceSignal() const override
Definition: yaml_export.h:103
corbo::MatrixSignal
Signal containing a simple matrix.
Definition: signals.h:561
corbo::YamlExporter::emitSignalGroup
void emitSignalGroup(const CommonSignalTarget::SignalGroup &signal_group, YAML::Emitter &emitter, bool wrap_in_map=true)
corbo::YamlExporter::isSupportingIndexedValuesSignal
bool isSupportingIndexedValuesSignal() const override
Definition: yaml_export.h:104
corbo::YamlExporter::write_file
bool write_file(const YAML::Emitter &emitter, const std::string &filename)
corbo::CommonSignalTarget::SignalGroup
Tree node containing a group of signals and a set of child tree nodes.
Definition: common_signal_target.h:101
corbo::YamlExporter::emitHeader
void emitHeader(const SignalHeader &header, YAML::Emitter &emitter)


control_box_rst
Author(s): Christoph Rösmann
autogenerated on Wed Mar 2 2022 00:07:16