libdballe  8.3
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 
11 namespace wreport {
12 struct Bulletin;
13 }
14 
15 namespace dballe {
16 
25 {
27  std::string template_name;
29  int centre = MISSING_INT;
31  int subcentre = MISSING_INT;
33  int application = MISSING_INT;
34 
35 
36  bool operator==(const ExporterOptions&) const;
37  bool operator!=(const ExporterOptions&) const;
38 
40  void print(FILE* out);
41 
43  std::string to_string() const;
44 
46  static std::unique_ptr<ExporterOptions> create();
47 
48  static const ExporterOptions defaults;
49 
50  friend class Exporter;
51 
52 protected:
54  ExporterOptions() = default;
55  ExporterOptions(const ExporterOptions&) = default;
56  ExporterOptions(ExporterOptions&&) = default;
57  ExporterOptions& operator=(const ExporterOptions&) = default;
58  ExporterOptions& operator=(ExporterOptions&&) = default;
59 };
60 
61 
65 class Exporter
66 {
67 protected:
68  ExporterOptions opts;
69 
70  Exporter(const ExporterOptions& opts);
71 
72 public:
73  Exporter(const Exporter&) = delete;
74  Exporter(Exporter&&) = delete;
75  virtual ~Exporter();
76 
77  Exporter& operator=(const Exporter&) = delete;
78  Exporter& operator=(Exporter&&) = delete;
79 
88  virtual std::string to_binary(const std::vector<std::shared_ptr<Message>>& messages) const = 0;
89 
93  virtual std::unique_ptr<wreport::Bulletin> to_bulletin(const std::vector<std::shared_ptr<Message>>& msgs) const = 0;
94 
101  virtual std::unique_ptr<wreport::Bulletin> make_bulletin() const;
102 
103 
105  static std::unique_ptr<Exporter> create(Encoding type, const ExporterOptions& opts=ExporterOptions::defaults);
106 };
107 
108 }
109 
110 #endif
Message exporter interface.
Definition: exporter.h:65
Definition: cmdline.h:18
std::string template_name
Name of template to use for output (leave empty to autodetect)
Definition: exporter.h:27
Options to control message export.
Definition: exporter.h:24