libdballe
6.8
Main Page
Modules
Data Structures
Files
File List
Globals
dballe
memdb
memdb.h
1
/*
2
* memdb/memdb - In-memory indexed storage of DB-All.e data
3
*
4
* Copyright (C) 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 DBA_MEMDB_MEMDB_H
23
#define DBA_MEMDB_MEMDB_H
24
25
#include <dballe/memdb/station.h>
26
#include <dballe/memdb/stationvalue.h>
27
#include <dballe/memdb/levtr.h>
28
#include <dballe/memdb/value.h>
29
30
namespace
dballe
{
31
struct
Record;
32
struct
Msg;
33
34
namespace
memdb {
35
template
<
typename
T>
struct
Results;
36
41
struct
SummaryContext
42
{
43
const
Value
& sample;
44
45
SummaryContext
(
const
Value
& val) : sample(val) {}
46
47
bool
operator<(
const
SummaryContext
& c)
const
;
48
};
49
51
struct
SummaryStats
52
{
53
size_t
count;
54
Datetime
dtmin;
55
Datetime
dtmax;
56
57
SummaryStats
(
const
Datetime
& dt) : count(1), dtmin(dt), dtmax(dt) {}
58
59
void
extend(
const
Datetime
& dt);
60
};
61
63
typedef
std::map<memdb::SummaryContext, memdb::SummaryStats> Summary;
64
66
struct
Summarizer
67
{
68
Summary& summary;
69
70
Summarizer
(Summary& summary) : summary(summary) {}
71
72
void
insert(
const
Value
* val);
73
};
74
75
}
76
78
struct
Memdb
79
{
80
memdb::Stations
stations;
81
memdb::StationValues
stationvalues;
82
memdb::LevTrs
levtrs;
83
memdb::Values
values;
84
85
Memdb
();
86
87
void
clear();
88
void
insert_or_replace(
const
Record
& rec);
89
void
insert(
const
Msg
& msg,
bool
replace=
true
,
bool
with_station_info=
true
,
bool
with_attrs=
true
,
const
char
* force_report=NULL);
90
size_t
insert(
91
const
Coord
& coords,
const
std::string& ident,
const
std::string& report,
92
const
Level
& level,
const
Trange
& trange,
const
Datetime
& datetime,
93
std::auto_ptr<wreport::Var> var);
94
size_t
insert(
95
const
Coord
& coords,
const
std::string& ident,
const
std::string& report,
96
const
Level
& level,
const
Trange
& trange,
const
Datetime
& datetime,
97
const
wreport::Var& var);
98
99
void
remove
(
memdb::Results<memdb::Value>
& query);
100
101
void
dump(FILE* out)
const
;
102
103
private
:
104
Memdb
(
const
Memdb
&);
105
Memdb
& operator=(
const
Memdb
&);
106
};
107
108
}
109
110
#endif
111
dballe::Msg
Storage for related physical data.
Definition:
msg.h:119
dballe::Memdb
In-memory database backend.
Definition:
memdb.h:78
dballe::memdb::Summarizer
Build a summary one Value at a time.
Definition:
memdb.h:66
dballe::memdb::StationValues
Storage and index for station information.
Definition:
stationvalue.h:58
dballe::memdb::LevTrs
Storage and index for station information.
Definition:
levtr.h:63
dballe::Trange
Definition:
defs.h:113
dballe::memdb::SummaryStats
Statistics about all 'Value's with the same SummaryContext.
Definition:
memdb.h:51
dballe::Record
DB-All.E record.
Definition:
record.h:102
dballe
Definition:
cmdline.h:34
dballe::memdb::Value
Station information.
Definition:
value.h:43
dballe::Level
Definition:
defs.h:54
dballe::memdb::Stations
Storage and index for station information.
Definition:
memdb/station.h:78
dballe::Coord
Coordinates.
Definition:
defs.h:167
dballe::Datetime
Simple datetime structure.
Definition:
defs.h:276
dballe::memdb::Values
Storage and index for station information.
Definition:
value.h:61
dballe::memdb::SummaryContext
Wraps a Value providing a std::map key that considers all values the same as long as they have the sa...
Definition:
memdb.h:41
dballe::memdb::Results
Definition:
levtr.h:33
Generated by
1.8.9.1