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 
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_
Signal for a sequence of time series objects.
Definition: signals.h:333
Time Series (trajectory resp. sequence of values w.r.t. time)
Definition: time_series.h:54
bool exportTimeSeriesSignal(const std::string &filename, const TimeSeriesSignal &signal) override
bool exportIndexedValuesSetSignal(const std::string &filename, const IndexedValuesSetSignal &signal) override
bool exportTimeSeries(const std::string &filename, const TimeSeries &time_series) override
void emitIndexedValuesSet(const IndexedValuesSetSignal &signal, YAML::Emitter &emitter, bool wrap_in_map=true)
void emitTimeSeriesSequence(const TimeSeriesSequenceSignal &signal, YAML::Emitter &emitter, bool wrap_in_map=true)
void emitIndexedValues(const IndexedValuesSignal &signal, YAML::Emitter &emitter, bool wrap_in_map=true)
bool isSupportingSignalGroup() const override
Definition: yaml_export.h:56
bool exportMatrixSetSignal(const std::string &filename, const MatrixSetSignal &signal) override
std::string getFileSuffix() const override
Definition: yaml_export.h:54
void emitHeader(const SignalHeader &header, YAML::Emitter &emitter)
bool write_file(const YAML::Emitter &emitter, const std::string &filename)
Signal containing a set of matrices.
Definition: signals.h:607
bool isSupportingTimeSeries() const override
Definition: yaml_export.h:58
Signal containing values indexed by a single integer.
Definition: signals.h:390
bool exportSignalGroup(const std::string &filename, const CommonSignalTarget::SignalGroup &signal_group) override
bool exportTimeSeriesSequenceSignal(const std::string &filename, const TimeSeriesSequenceSignal &signal) override
DataExporterInterface::Ptr getInstance() const override
Return a newly created shared instance of the implemented class.
Definition: yaml_export.h:51
bool exportIndexedValuesSignal(const std::string &filename, const IndexedValuesSignal &signal) override
bool isSupportingTimeSeriesSequenceSignal() const override
Definition: yaml_export.h:59
void emitMatrix(const MatrixSignal &signal, YAML::Emitter &emitter, bool wrap_in_map=true)
bool isSupportingMatrixSetSignal() const override
Definition: yaml_export.h:63
bool exportMatrixSignal(const std::string &filename, const MatrixSignal &signal) override
Export yaml files.
Definition: yaml_export.h:44
Time Series signal (trajectory resp. sequence of values w.r.t. time)
Definition: signals.h:244
bool isSupportingTimeSeriesSignal() const override
Definition: yaml_export.h:57
FACTORY_REGISTER_DATA_EXPORTER(TsvExporter)
Signal containing a simple matrix.
Definition: signals.h:539
bool isSupportingIndexedValuesSignal() const override
Definition: yaml_export.h:60
std::string getFormatName() const override
Definition: yaml_export.h:53
void emitSignalGroup(const CommonSignalTarget::SignalGroup &signal_group, YAML::Emitter &emitter, bool wrap_in_map=true)
void emitMatrixSet(const MatrixSetSignal &signal, YAML::Emitter &emitter, bool wrap_in_map=true)
Interface class for exporting signals.
void emitTimeSeries(const TimeSeries &time_series, YAML::Emitter &emitter, bool wrap_in_map=true)
bool isSupportingMatrixSignal() const override
Definition: yaml_export.h:62
Signal header.
Definition: signals.h:75
Tree node containing a group of signals and a set of child tree nodes.
bool isSupportingIndexedValuesSetSignal() const override
Definition: yaml_export.h:61
std::shared_ptr< DataExporterInterface > Ptr
Signal containing values indexed by an integer (int to double[] map)
Definition: signals.h:474


control_box_rst
Author(s): Christoph Rösmann
autogenerated on Mon Feb 28 2022 22:07:59