libdballe 9.6
exporter.h
1#ifndef DBALLE_EXPORTER_H
2#define DBALLE_EXPORTER_H
3
4#include <dballe/fwd.h>
5#include <vector>
6#include <memory>
7#include <string>
8#include <cstdio>
9#include <functional>
10
11namespace wreport {
12struct Bulletin;
13}
14
15namespace dballe {
16
25{
26public:
28 std::string template_name;
30 int centre = MISSING_INT;
32 int subcentre = MISSING_INT;
34 int application = MISSING_INT;
35
36
37 bool operator==(const ExporterOptions&) const;
38 bool operator!=(const ExporterOptions&) const;
39
41 void print(FILE* out);
42
44 std::string to_string() const;
45
47 static std::unique_ptr<ExporterOptions> create();
48
49 static const ExporterOptions defaults;
50
51 friend class Exporter;
52
53protected:
55 ExporterOptions() = default;
56 ExporterOptions(const ExporterOptions&) = default;
58 ExporterOptions& operator=(const ExporterOptions&) = default;
59 ExporterOptions& operator=(ExporterOptions&&) = default;
60};
61
62
67{
68protected:
69 ExporterOptions opts;
70
71 Exporter(const ExporterOptions& opts);
72
73public:
74 Exporter(const Exporter&) = delete;
75 Exporter(Exporter&&) = delete;
76 virtual ~Exporter();
77
78 Exporter& operator=(const Exporter&) = delete;
79 Exporter& operator=(Exporter&&) = delete;
80
89 virtual std::string to_binary(const std::vector<std::shared_ptr<Message>>& messages) const = 0;
90
94 virtual std::unique_ptr<wreport::Bulletin> to_bulletin(const std::vector<std::shared_ptr<Message>>& msgs) const;
95
102 virtual std::unique_ptr<wreport::Bulletin> make_bulletin() const;
103
104
106 static std::unique_ptr<Exporter> create(Encoding type, const ExporterOptions& opts=ExporterOptions::defaults);
107};
108
110{
111public:
112 using Exporter::Exporter;
113
117 std::unique_ptr<wreport::Bulletin> to_bulletin(const std::vector<std::shared_ptr<Message>>& msgs) const override = 0;
118};
119
120}
121
122#endif
Definition: exporter.h:110
std::unique_ptr< wreport::Bulletin > to_bulletin(const std::vector< std::shared_ptr< Message > > &msgs) const override=0
Export to a Bulletin.
Options to control message export.
Definition: exporter.h:25
std::string to_string() const
Generate a string summary of export options.
std::string template_name
Name of template to use for output (leave empty to autodetect)
Definition: exporter.h:28
int centre
Originating centre.
Definition: exporter.h:30
int subcentre
Originating subcentre.
Definition: exporter.h:32
ExporterOptions()=default
Create new Options initialised with default values.
int application
Originating application ID.
Definition: exporter.h:34
static std::unique_ptr< ExporterOptions > create()
Create with default values.
void print(FILE *out)
Print a summary of the options to out.
Message exporter interface.
Definition: exporter.h:67
virtual std::string to_binary(const std::vector< std::shared_ptr< Message > > &messages) const =0
Encode a message.
static std::unique_ptr< Exporter > create(Encoding type, const ExporterOptions &opts=ExporterOptions::defaults)
Instantiate the right importer for the given type.
virtual std::unique_ptr< wreport::Bulletin > to_bulletin(const std::vector< std::shared_ptr< Message > > &msgs) const
Export to a Bulletin.
virtual std::unique_ptr< wreport::Bulletin > make_bulletin() const
Create a bulletin that works with this exporter.