libdballe
7.6
Main Page
Modules
Namespaces
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
Coords
& coords,
const
std::string& ident,
const
std::string& report,
92
const
Level
& level,
const
Trange
& trange,
const
Datetime
& datetime,
93
std::unique_ptr<wreport::Var> var);
94
size_t
insert(
95
const
Coords
& 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::StationValue>
& query);
100
void
remove
(
memdb::Results<memdb::Value>
& query);
101
102
void
dump(FILE* out)
const
;
103
104
private
:
105
Memdb
(
const
Memdb
&);
106
Memdb
& operator=(
const
Memdb
&);
107
};
108
109
}
110
111
#endif
112
dballe::Msg
Storage for related physical data.
Definition:
msg.h:133
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::Coords
Coordinates.
Definition:
types.h:320
dballe::memdb::StationValues
Storage and index for station values.
Definition:
stationvalue.h:41
dballe::memdb::LevTrs
Storage and index for level and time range aggregate sets.
Definition:
memdb/levtr.h:46
dballe::Trange
Information on how a value has been sampled or computed with regards to time.
Definition:
types.h:565
dballe::memdb::SummaryStats
Statistics about all 'Value's with the same SummaryContext.
Definition:
memdb.h:51
dballe::Record
Key/value store where keys are strings and values are wreport variables.
Definition:
record.h:16
dballe
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition:
cmdline.h:17
dballe::memdb::Value
A value measured by a station.
Definition:
value.h:25
dballe::Level
Vertical level or layer.
Definition:
types.h:515
dballe::memdb::Stations
Storage and index for station information.
Definition:
memdb/station.h:62
dballe::Datetime
Date and time.
Definition:
types.h:147
dballe::memdb::Values
Storage and index for measured values.
Definition:
value.h:43
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:
memdb/levtr.h:16
Generated by
1.8.9.1