libdballe  6.8
msgapi.h
1 #ifndef FDBA_MSGAPI_H
2 #define FDBA_MSGAPI_H
3 
4 /*
5  * Copyright (C) 2005--2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  *
20  * Author: Enrico Zini <enrico@enricozini.com>
21  */
22 
23 #include "commonapi.h"
24 #include <dballe/core/defs.h>
25 
26 namespace wreport {
27 struct Var;
28 }
29 
30 namespace dballe {
31 struct File;
32 struct Msgs;
33 struct Msg;
34 
35 namespace msg {
36 struct Importer;
37 struct Exporter;
38 }
39 
40 namespace fortran {
41 
43 {
44 protected:
45  enum {
46  STATE_BLANK = 1,
47  STATE_QUANTESONO = 2,
48  STATE_VOGLIOQUESTO = 4,
49  STATE_EOF = 8,
50  };
51  File* file;
56  unsigned int state;
62  std::string exporter_template;
68  std::vector<wreport::Var*> vars;
73  size_t curmsgidx;
74  int iter_ctx;
75  int iter_var;
82 
83 
89  bool readNextMessage();
90 
96  bool incrementMsgIters();
97 
101  Msg* curmsg();
102 
103  void flushVars();
104  void flushSubset();
105  void flushMessage();
106 
107 public:
117  MsgAPI(const char* fname, const char* mode, const char* type);
118  virtual ~MsgAPI();
119 
120  virtual void scopa(const char* repinfofile = 0);
121 
122  virtual int quantesono();
123  virtual void elencamele();
124 
125  virtual int voglioquesto();
126  virtual const char* dammelo();
127 
128  virtual void prendilo();
129  virtual void dimenticami();
130 
131  virtual int voglioancora();
132 
133  virtual void critica();
134  virtual void scusa();
135  virtual void remove_all();
136  virtual void messages_open_input(const char* filename, const char* mode, Encoding format, bool);
137  virtual void messages_open_output(const char* filename, const char* mode, Encoding format);
138  virtual bool messages_read_next();
139  virtual void messages_write_next(const char*);
140 };
141 
142 }
143 }
144 
145 /* vim:set ts=4 sw=4: */
146 #endif
std::vector< wreport::Var * > vars
Last variables written with prendilo.
Definition: msgapi.h:68
virtual void messages_open_input(const char *filename, const char *mode, Encoding format, bool)
Open a BUFR/CREX/AOF file for reading.
virtual void messages_open_output(const char *filename, const char *mode, Encoding format)
Open a BUFR/CREX/AOF file for writing.
virtual void critica()
Insert new QC informations for a variable of the current record.
Trange vars_trange
Time range for vars.
Definition: msgapi.h:72
virtual void messages_write_next(const char *)
Export the currently selected data to the output message.
Level vars_level
Level for vars.
Definition: msgapi.h:70
virtual void elencamele()
Iterate through the anagraphical data.
Storage for related physical data.
Definition: msg.h:119
virtual void remove_all()
Remove all data from the database.
Common implementation of the set* and enq* machinery using input and output records.
Definition: commonapi.h:35
unsigned int state
State flag to track what actions have been performed in order to decide what to do next...
Definition: msgapi.h:56
MsgAPI(const char *fname, const char *mode, const char *type)
Definition: defs.h:113
Common definitions.
Message importer.
Definition: codec.h:53
Definition: cmdline.h:34
msg::Importer * importer
Importer (NULL if we export)
Definition: msgapi.h:58
msg::Exporter * exporter
Exporter (NULL if we import)
Definition: msgapi.h:60
Definition: defs.h:54
virtual void dimenticami()
Remove all selected items from the database.
Msg * wmsg
Message subset being written.
Definition: msgapi.h:66
int cached_lcat
Local category set for the message that we are writing.
Definition: msgapi.h:81
Definition: file.h:46
int cached_subcat
Subcategory set for the message that we are writing.
Definition: msgapi.h:79
bool readNextMessage()
Read the next message.
Msg * curmsg()
Get a pointer to the current message being read or written.
virtual bool messages_read_next()
Read the next message and import it in the database.
virtual int voglioancora()
Retrieve QC informations from the last variable returned by dammelo().
Definition: conversion.h:31
Dynamic array of dba_msg.
Definition: msgs.h:38
virtual void scusa()
Remove QC informations for a variable of the current record.
virtual void prendilo()
Insert a new item in the database.
Msgs * msgs
Message being written.
Definition: msgapi.h:64
virtual const char * dammelo()
Iterate through the query results data.
Message exporter.
Definition: codec.h:111
virtual int voglioquesto()
Submit a query to the database.
std::string exporter_template
Template selected for exporter (empty if auto detect)
Definition: msgapi.h:62
virtual void scopa(const char *repinfofile=0)
Reset the database contents, loading default report informations from a file.
int cached_cat
Category set for the message that we are writing.
Definition: msgapi.h:77
virtual int quantesono()
Count the number of elements in the anagraphical storage, and start a new anagraphical query...
Definition: msgapi.h:42
bool incrementMsgIters()
Increment message iterators.