libdballe  7.7
dbapi.h
1 #ifndef FDBA_DBAPI_H
2 #define FDBA_DBAPI_H
3 
4 #include "commonapi.h"
5 #include <dballe/file.h>
6 
7 namespace dballe {
8 struct DB;
9 
10 namespace db {
11 struct CursorStation;
12 struct CursorValue;
13 }
14 
15 namespace fortran {
16 
17 struct InputFile;
18 struct OutputFile;
19 
21 {
22 protected:
23  DB& db;
24  db::CursorStation* ana_cur;
25  db::CursorValue* query_cur;
26  InputFile* input_file;
27  OutputFile* output_file;
28  int last_inserted_station_id;
29 
31  struct VarID
32  {
33  wreport::Varcode code;
34  // True if it is a station value
35  bool station;
36  size_t id;
37  VarID(wreport::Varcode code, bool station, size_t id) : code(code), station(station), id(id) {}
38  };
39 
41  std::vector<VarID> last_inserted_varids;
42 
43 
44 public:
45  DbAPI(DB& db, const char* anaflag, const char* dataflag, const char* attrflag);
46  virtual ~DbAPI();
47 
48  virtual int enqi(const char* param);
49 
50  virtual void scopa(const char* repinfofile = 0);
51  virtual void remove_all();
52 
53  virtual int quantesono();
54  virtual void elencamele();
55 
56  virtual int voglioquesto();
57  virtual const char* dammelo();
58 
59  virtual void prendilo();
60  virtual void dimenticami();
61 
62  virtual int voglioancora();
63 
64  virtual void critica();
65  virtual void scusa();
66 
67  virtual void messages_open_input(const char* filename, const char* mode, File::Encoding format, bool simplified=true);
68  virtual void messages_open_output(const char* filename, const char* mode, File::Encoding format);
69  virtual bool messages_read_next();
70  virtual void messages_write_next(const char* template_name=0);
71 };
72 
73 }
74 }
75 
76 #endif
virtual bool messages_read_next()
Read the next message and import it in the database.
Common interface for cursors iterating over station or data values.
Definition: db.h:103
Encoding
Supported encodings.
Definition: file.h:20
Store information about the database ID of a variable.
Definition: dbapi.h:31
virtual void scusa()
Remove QC informations for a variable of the current record.
virtual int voglioquesto()
Submit a query to the database.
Common implementation of the set* and enq* machinery using input and output records.
Definition: commonapi.h:14
Definition: dbapi.h:20
virtual int quantesono()
Count the number of elements in the anagraphical storage, and start a new anagraphical query...
virtual void prendilo()
Insert a new item in the database.
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
Cursor iterating over stations.
Definition: db.h:98
virtual const char * dammelo()
Iterate through the query results data.
virtual void messages_open_output(const char *filename, const char *mode, File::Encoding format)
Open a BUFR/CREX/AOF file for writing.
virtual void scopa(const char *repinfofile=0)
Reset the database contents, loading default report informations from a file.
virtual void remove_all()
Remove all data from the database.
std::vector< VarID > last_inserted_varids
Store database variable IDs for all last inserted variables.
Definition: dbapi.h:41
virtual int voglioancora()
Retrieve QC informations from the last variable returned by dammelo().
virtual void messages_open_input(const char *filename, const char *mode, File::Encoding format, bool simplified=true)
Open a BUFR/CREX/AOF file for reading.
Definition: db.h:182
virtual void elencamele()
Iterate through the anagraphical data.
virtual void critica()
Insert new QC informations for a variable of the current record.
virtual void messages_write_next(const char *template_name=0)
Export the currently selected data to the output message.
virtual int enqi(const char *param)
Read one integer value from the output record.
virtual void dimenticami()
Remove all selected items from the database.