libdballe  6.8
db/v5/context.h
Go to the documentation of this file.
1 /*
2  * db/context - context table management
3  *
4  * Copyright (C) 2005--2013 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 DBALLE_DB_V5_CONTEXT_H
23 #define DBALLE_DB_V5_CONTEXT_H
24 
32 #include <sqltypes.h>
33 #include <cstdio>
34 
35 namespace dballe {
36 namespace db {
37 struct Connection;
38 struct Statement;
39 
40 namespace v5 {
41 struct DB;
42 
46 struct Context
47 {
52 
61 
63  DBALLE_SQL_C_SINT_TYPE id;
64 
66  DBALLE_SQL_C_SINT_TYPE id_station;
68  DBALLE_SQL_C_SINT_TYPE id_report;
70  SQL_TIMESTAMP_STRUCT date;
72  DBALLE_SQL_C_SINT_TYPE ltype1;
74  DBALLE_SQL_C_SINT_TYPE l1;
76  DBALLE_SQL_C_SINT_TYPE ltype2;
78  DBALLE_SQL_C_SINT_TYPE l2;
80  DBALLE_SQL_C_SINT_TYPE pind;
82  DBALLE_SQL_C_SINT_TYPE p1;
84  DBALLE_SQL_C_SINT_TYPE p2;
85 
86  Context(v5::DB& db);
87  ~Context();
88 
95  int get_id();
96 
103  void get_data(int id);
104 
113  int obtain_station_info();
114 
121  int insert();
122 
126  void remove();
127 
131  void dump(FILE* out);
132 
133 private:
134  // disallow copy
135  Context(const Context&);
136  Context& operator=(const Context&);
137 };
138 
139 } // namespace v5
140 } // namespace db
141 } // namespace dballe
142 
143 /* vim:set ts=4 sw=4: */
144 #endif
v5::DB & db
DB connection.
Definition: db/v5/context.h:51
DB-ALLe database connection.
Definition: v5/db.h:83
db::Statement * sdstm
Precompiled select data statement.
Definition: db/v5/context.h:56
DBALLE_SQL_C_SINT_TYPE pind
Time range type SQL parameter.
Definition: db/v5/context.h:80
void get_data(int id)
Get context information given a context ID.
int obtain_station_info()
Get the context id for a station info context.
Precompiled queries to manipulate the context table.
Definition: db/v5/context.h:46
The ODBC specification is imperfect with regards to integer sizes on 64bit platforms, and different ODBC drivers are currently interpreting it differently.
DBALLE_SQL_C_SINT_TYPE ltype1
First level type SQL parameter.
Definition: db/v5/context.h:72
Definition: cmdline.h:34
DBALLE_SQL_C_SINT_TYPE l1
Level L1 SQL parameter.
Definition: db/v5/context.h:74
DBALLE_SQL_C_SINT_TYPE ltype2
Second level type SQL parameter.
Definition: db/v5/context.h:76
DBALLE_SQL_C_SINT_TYPE p1
Time range P1 SQL parameter.
Definition: db/v5/context.h:82
int insert()
Insert a new context in the database.
DBALLE_SQL_C_SINT_TYPE id_station
Station ID SQL parameter.
Definition: db/v5/context.h:66
DBALLE_SQL_C_SINT_TYPE id_report
Report ID SQL parameter.
Definition: db/v5/context.h:68
db::Statement * istm
Precompiled insert statement.
Definition: db/v5/context.h:58
DBALLE_SQL_C_SINT_TYPE id
Context ID SQL parameter.
Definition: db/v5/context.h:63
DBALLE_SQL_C_SINT_TYPE l2
Level L2 SQL parameter.
Definition: db/v5/context.h:78
int get_id()
Get the context id for the current context data.
ODBC statement.
Definition: internals.h:220
DBALLE_SQL_C_SINT_TYPE p2
Time range P2 SQL parameter.
Definition: db/v5/context.h:84
db::Statement * dstm
Precompiled delete statement.
Definition: db/v5/context.h:60
void dump(FILE *out)
Dump the entire contents of the table to an output stream.
db::Statement * sstm
Precompiled select statement.
Definition: db/v5/context.h:54
SQL_TIMESTAMP_STRUCT date
Date SQL parameter.
Definition: db/v5/context.h:70