libdballe  6.8
lev_tr.h
Go to the documentation of this file.
1 /*
2  * db/v6/lev_tr - lev_tr 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_V6_LEV_TR_H
23 #define DBALLE_DB_V6_LEV_TR_H
24 
32 #include <dballe/core/defs.h>
33 #include <sqltypes.h>
34 #include <cstdio>
35 #include <memory>
36 
37 namespace dballe {
38 struct Record;
39 struct Msg;
40 
41 namespace msg {
42 struct Context;
43 }
44 
45 namespace db {
46 struct Connection;
47 struct Statement;
48 
49 namespace v6 {
50 struct DB;
51 
55 struct LevTr
56 {
60  DB& db;
61 
70 
72  DBALLE_SQL_C_SINT_TYPE id;
73 
75  DBALLE_SQL_C_SINT_TYPE ltype1;
77  DBALLE_SQL_C_SINT_TYPE l1;
79  DBALLE_SQL_C_SINT_TYPE ltype2;
81  DBALLE_SQL_C_SINT_TYPE l2;
83  DBALLE_SQL_C_SINT_TYPE pind;
85  DBALLE_SQL_C_SINT_TYPE p1;
87  DBALLE_SQL_C_SINT_TYPE p2;
88 
89  LevTr(DB& db);
90  ~LevTr();
91 
98  int get_id();
99 
106  void get_data(int id);
107 
114  int insert();
115 
119  void remove();
120 
124  void dump(FILE* out);
125 
126 private:
127  // disallow copy
128  LevTr(const LevTr&);
129  LevTr& operator=(const LevTr&);
130 };
131 
133 {
134  virtual ~LevTrCache();
135 
141  virtual bool to_rec(int id, Record& rec) = 0;
142 
144  virtual Level to_level(int id) const = 0;
145 
147  virtual Trange to_trange(int id) const = 0;
148 
154  virtual msg::Context* to_msg(int id, Msg& msg) = 0;
155 
157  virtual void invalidate() = 0;
158 
160  virtual void dump(FILE* out) const = 0;
161 
162  static std::auto_ptr<LevTrCache> create(LevTr& lt);
163 };
164 
165 } // namespace v6
166 } // namespace db
167 } // namespace dballe
168 
169 /* vim:set ts=4 sw=4: */
170 #endif
Store an array of physical data all on the same level.
Definition: msg/context.h:44
db::Statement * dstm
Precompiled delete statement.
Definition: lev_tr.h:69
Storage for related physical data.
Definition: msg.h:119
virtual msg::Context * to_msg(int id, Msg &msg)=0
Get/create a Context in the Msg for this level/timerange.
Definition: defs.h:113
The ODBC specification is imperfect with regards to integer sizes on 64bit platforms, and different ODBC drivers are currently interpreting it differently.
Common definitions.
DBALLE_SQL_C_SINT_TYPE p1
Time range P1 SQL parameter.
Definition: lev_tr.h:85
int get_id()
Get the lev_tr id for the current lev_tr data.
DBALLE_SQL_C_SINT_TYPE pind
Time range type SQL parameter.
Definition: lev_tr.h:83
DB-All.E record.
Definition: record.h:102
virtual bool to_rec(int id, Record &rec)=0
Fill a record with level/timerange info with this id.
void dump(FILE *out)
Dump the entire contents of the table to an output stream.
Definition: cmdline.h:34
DBALLE_SQL_C_SINT_TYPE ltype2
Second level type SQL parameter.
Definition: lev_tr.h:79
int insert()
Insert a new lev_tr in the database.
virtual Level to_level(int id) const =0
Return a Level for this ID.
Definition: lev_tr.h:132
Definition: defs.h:54
DBALLE_SQL_C_SINT_TYPE id
lev_tr ID SQL parameter
Definition: lev_tr.h:72
DB & db
DB connection.
Definition: lev_tr.h:60
virtual void dump(FILE *out) const =0
Dump cache contents to an output stream.
DBALLE_SQL_C_SINT_TYPE l1
Level L1 SQL parameter.
Definition: lev_tr.h:77
db::Statement * sstm
Precompiled select statement.
Definition: lev_tr.h:63
Precompiled queries to manipulate the lev_tr table.
Definition: lev_tr.h:55
ODBC statement.
Definition: internals.h:220
DBALLE_SQL_C_SINT_TYPE ltype1
First level type SQL parameter.
Definition: lev_tr.h:75
virtual Trange to_trange(int id) const =0
Return a Trange for this ID.
virtual void invalidate()=0
Invalidate the cache.
DB-ALLe database connection.
Definition: v6/db.h:87
db::Statement * istm
Precompiled insert statement.
Definition: lev_tr.h:67
db::Statement * sdstm
Precompiled select data statement.
Definition: lev_tr.h:65
DBALLE_SQL_C_SINT_TYPE p2
Time range P2 SQL parameter.
Definition: lev_tr.h:87
void get_data(int id)
Get lev_tr information given a lev_tr ID.
DBALLE_SQL_C_SINT_TYPE l2
Level L2 SQL parameter.
Definition: lev_tr.h:81