libdballe  7.6
value.h
1 #ifndef DBA_MEMDB_VALUE_H
2 #define DBA_MEMDB_VALUE_H
3 
4 #include <dballe/memdb/valuestorage.h>
5 #include <dballe/memdb/index.h>
6 #include <dballe/memdb/valuebase.h>
7 #include <dballe/core/defs.h>
8 #include <wreport/var.h>
9 #include <memory>
10 #include <iosfwd>
11 
12 namespace dballe {
13 struct Record;
14 
15 namespace core {
16 struct Query;
17 }
18 
19 namespace memdb {
20 template<typename T> struct Results;
21 struct Station;
22 struct LevTr;
23 
25 struct Value : public ValueBase
26 {
27  const Station& station;
28  const LevTr& levtr;
29  Datetime datetime;
30 
31  Value(const Station& station, const LevTr& levtr, const Datetime& datetime, std::unique_ptr<wreport::Var> var)
32  : ValueBase(std::move(var)), station(station), levtr(levtr), datetime(datetime) {}
33  ~Value();
34 
35  void dump(FILE* out) const;
36 
37 private:
38  Value(const Value&);
39  Value& operator=(const Value&);
40 };
41 
43 class Values : public ValueStorage<Value>
44 {
45 protected:
46  Index<const Station*> by_station;
47  Index<const LevTr*> by_levtr;
48  Index<Date> by_date;
49 
50 public:
51  void clear();
52 
54  size_t insert(const Station& station, const LevTr& levtr, const Datetime& datetime, std::unique_ptr<wreport::Var> var, bool replace=true);
55 
57  size_t insert(const Station& station, const LevTr& levtr, const Datetime& datetime, const wreport::Var& var, bool replace=true);
58 
64  bool remove(const Station& station, const LevTr& levtr, const Datetime& datetime, wreport::Varcode code);
65 
67  void erase(size_t idx);
68 
70  void query(const core::Query& q, Results<Station>& stations, Results<LevTr>& levtrs, Results<Value>& res) const;
71 
72  void dump(FILE* out) const;
73 };
74 
75 }
76 }
77 
78 #endif
Station information.
Definition: valuebase.h:36
Aggregated level and time range information.
Definition: memdb/levtr.h:19
Definition: mem/cursor.h:14
void erase(size_t idx)
Removes a value, by index.
Standard dballe::Query implementation.
Definition: core/query.h:29
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
A value measured by a station.
Definition: value.h:25
Station information.
Definition: memdb/station.h:27
size_t insert(const Station &station, const LevTr &levtr, const Datetime &datetime, std::unique_ptr< wreport::Var > var, bool replace=true)
Insert a new value, or replace an existing one.
Date and time.
Definition: types.h:147
Index element positions based by one value.
Definition: index.h:41
Storage and index for measured values.
Definition: value.h:43
Common definitions.
Definition: memdb/levtr.h:16
void query(const core::Query &q, Results< Station > &stations, Results< LevTr > &levtrs, Results< Value > &res) const
Query values returning the IDs.