libdballe  9.11
msgapi.h
1 #ifndef DBALLE_FORTRAN_MSGAPI_H
2 #define DBALLE_FORTRAN_MSGAPI_H
3 
4 #include "commonapi.h"
5 #include <dballe/fwd.h>
6 #include <dballe/msg/fwd.h>
7 #include <dballe/core/defs.h>
8 
9 namespace wreport {
10 struct Var;
11 }
12 
13 namespace dballe {
14 namespace fortran {
15 
17 {
18 protected:
19  enum {
20  STATE_BLANK = 1,
21  STATE_QUANTESONO = 2,
22  STATE_VOGLIOQUESTO = 4,
23  STATE_EOF = 8,
24  };
25  File* file;
30  unsigned int state;
34  std::string exporter_template;
36  Exporter* exporter = nullptr;
37  size_t curmsgidx;
44 
45 
51  bool readNextMessage();
52 
53 
54 public:
56  std::shared_ptr<impl::Message> wmsg = nullptr;
58  std::vector<std::shared_ptr<dballe::Message>>* msgs = nullptr;
59 
69  MsgAPI(const char* fname, const char* mode, const char* type);
70  virtual ~MsgAPI();
71 
75  const impl::Message* curmsg() const;
77  void flushSubset();
78  void flushMessage();
79  void set_exporter(const char* template_name);
80 
81  void reinit_db(const char* repinfofile=0) override;
82  int query_stations() override;
83  int query_data() override;
84  void insert_data() override;
85  void remove_data() override;
86  void remove_all() override;
87  void messages_open_input(const char* filename, const char* mode, Encoding format, bool) override;
88  void messages_open_output(const char* filename, const char* mode, Encoding format) override;
89  bool messages_read_next() override;
90  void messages_write_next(const char*) override;
91 };
92 
93 }
94 }
95 #endif
Importer * importer
Importer (NULL if we export)
Definition: msgapi.h:32
const impl::Message * curmsg() const
Get a pointer to the current message being read or written.
Message importer interface.
Definition: importer.h:71
Common implementation of the set* and enq* machinery using input and output records.
Definition: commonapi.h:152
unsigned int state
State flag to track what actions have been performed in order to decide what to do next...
Definition: msgapi.h:30
MsgAPI(const char *fname, const char *mode, const char *type)
Message exporter interface.
Definition: exporter.h:66
Definition: cmdline.h:18
std::vector< std::shared_ptr< dballe::Message > > * msgs
Message being written.
Definition: msgapi.h:58
int cached_lcat
Local category set for the message that we are writing.
Definition: msgapi.h:43
File object for doing I/O on binary message streams.
Definition: file.h:17
int cached_subcat
Subcategory set for the message that we are writing.
Definition: msgapi.h:41
bool readNextMessage()
Read the next message.
Exporter * exporter
Exporter (NULL if we import)
Definition: msgapi.h:36
Common definitions.
std::shared_ptr< impl::Message > wmsg
Message subset being written.
Definition: msgapi.h:56
Storage for related physical data.
Definition: msg.h:130
std::string exporter_template
Name of the last exporter template set.
Definition: msgapi.h:34
int cached_cat
Category set for the message that we are writing.
Definition: msgapi.h:39
Definition: msgapi.h:16