libdballe  6.8
commonapi.h
1 /*
2  * fortran/commonapi - Common parts of all Fortran API implementations
3  *
4  * Copyright (C) 2005--2014 ARPA-SIM <urpsim@smr.arpa.emr.it>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * Author: Enrico Zini <enrico@enricozini.com>
20  */
21 
22 #ifndef FDBA_COMMONAPI_H
23 #define FDBA_COMMONAPI_H
24 
25 #include "simple.h"
26 #include <dballe/core/record.h>
27 
28 namespace dballe {
29 namespace fortran {
30 
36 {
37 public:
38  enum AttrState {
45  };
46 
47 protected:
48  enum {
49  PERM_ANA_RO = (1 << 0),
50  PERM_ANA_WRITE = (1 << 1),
51  PERM_DATA_RO = (1 << 2),
52  PERM_DATA_ADD = (1 << 3),
53  PERM_DATA_WRITE = (1 << 4),
54  PERM_ATTR_RO = (1 << 5),
55  PERM_ATTR_WRITE = (1 << 6)
56  };
57 
58  int perms;
59  Record input;
60  Record output;
61  Record qcinput;
62  Record qcoutput;
63  int qc_iter;
64  int qc_count;
65 
66  AttrState attr_state;
67 
68  // Varcode of the variable referred to by the next attribute operations
69  wreport::Varcode attr_varid;
70 
71  // Reference ID of the variable referred to by the next attribute operations
72  int attr_reference_id;
73 
74  // Last string returned by one of the spiega* functions, held here so
75  // that we can deallocate it when needed.
76  std::string cached_spiega;
77 
81  void set_permissions(const char* anaflag, const char* dataflag, const char* attrflag);
82 
87  Record& choose_input_record(const char*& param);
88 
93  Record& choose_output_record(const char*& param);
94 
96  void read_qc_list(std::vector<wreport::Varcode>& res_arr) const;
97 
98 public:
100  virtual ~CommonAPIImplementation();
101 
102  virtual void test_input_to_output();
103 
104  virtual int enqi(const char* param);
105  virtual signed char enqb(const char* param);
106  virtual float enqr(const char* param);
107  virtual double enqd(const char* param);
108  virtual const char* enqc(const char* param);
109 
110  virtual void seti(const char* param, int value);
111  virtual void setb(const char* param, signed char value);
112  virtual void setr(const char* param, float value);
113  virtual void setd(const char* param, double value);
114  virtual void setc(const char* param, const char* value);
115 
116  virtual void setcontextana();
117 
118  virtual void enqlevel(int& ltype1, int& l1, int& ltype2, int& l2);
119  virtual void setlevel(int ltype1, int l1, int ltype2, int l2);
120 
121  virtual void enqtimerange(int& ptype, int& p1, int& p2);
122  virtual void settimerange(int ptype, int p1, int p2);
123 
124  virtual void enqdate(int& year, int& month, int& day, int& hour, int& min, int& sec);
125  virtual void setdate(int year, int month, int day, int hour, int min, int sec);
126 
127  virtual void setdatemin(int year, int month, int day, int hour, int min, int sec);
128  virtual void setdatemax(int year, int month, int day, int hour, int min, int sec);
129 
130  virtual void unset(const char* param);
131  virtual void unsetall();
132  virtual void unsetb();
133 
134  virtual const char* spiegal(int ltype1, int l1, int ltype2, int l2);
135  virtual const char* spiegat(int ptype, int p1, int p2);
136  virtual const char* spiegab(const char* varcode, const char* value);
137 
138 
139  virtual const char* ancora();
140 
141  AttrState test_get_attr_state() const { return attr_state; }
142 };
143 
144 }
145 }
146 
147 /* vim:set ts=4 sw=4: */
148 #endif
virtual void setdatemax(int year, int month, int day, int hour, int min, int sec)
Shortcut function to set maximum date for a query.
Record & choose_input_record(const char *&param)
Choose the input record to use for param.
virtual void unset(const char *param)
Remove one parameter from the input record.
virtual void setb(const char *param, signed char value)
Set one byte value into the input record.
virtual void setdatemin(int year, int month, int day, int hour, int min, int sec)
Shortcut function to set minimum date for a query.
virtual void enqlevel(int &ltype1, int &l1, int &ltype2, int &l2)
Shortcut function to read level data.
virtual signed char enqb(const char *param)
Read one byte value from the output record.
virtual void seti(const char *param, int value)
Set one integer value into the input record.
Common implementation of the set* and enq* machinery using input and output records.
Definition: commonapi.h:35
virtual void setlevel(int ltype1, int l1, int ltype2, int l2)
Shortcut function to set level data.
DB-All.E record.
Definition: record.h:102
Definition: cmdline.h:34
Record & choose_output_record(const char *&param)
Choose the output record to use for param.
Definition: simple.h:29
virtual void setc(const char *param, const char *value)
Set one character value into the input record.
AttrState
Definition: commonapi.h:38
void read_qc_list(std::vector< wreport::Varcode > &res_arr) const
Reads the list of QC values to operate on, for dba_voglioancora and dba_scusa.
virtual int enqi(const char *param)
Read one integer value from the output record.
virtual void unsetall()
Remove all parameters from the input record.
virtual void enqtimerange(int &ptype, int &p1, int &p2)
Shortcut function to read time range data.
virtual void settimerange(int ptype, int p1, int p2)
Shortcut function to set time range data.
virtual double enqd(const char *param)
Read one real*8 value from the output record.
virtual void setr(const char *param, float value)
Set one real value into the input record.
Implement a storage object for a group of related observation data.
virtual const char * ancora()
Retrieve QC informations from the last variable returned by dammelo().
virtual float enqr(const char *param)
Read one real value from the output record.
virtual void unsetb()
Remove all B* parameters from the input record.
After a set *context_id or *var_related.
Definition: commonapi.h:44
virtual void enqdate(int &year, int &month, int &day, int &hour, int &min, int &sec)
Shortcut function to read date information.
virtual void setdate(int year, int month, int day, int hour, int min, int sec)
Shortcut function to set date information.
After a dammelo.
Definition: commonapi.h:40
virtual void setd(const char *param, double value)
Set one real*8 value into the input record.
virtual void setcontextana()
Shortcut function to set query parameters to the anagraphical context.
virtual const char * enqc(const char *param)
Read one character value from the output record.
After a prendilo.
Definition: commonapi.h:42
void set_permissions(const char *anaflag, const char *dataflag, const char *attrflag)
Set the permission bits, parsing the flags and doing consistency checks.