libdballe  7.7
stationvalue.h
1 #ifndef DBA_MEMDB_STATIONVALUE_H
2 #define DBA_MEMDB_STATIONVALUE_H
3 
4 #include <dballe/memdb/valuestorage.h>
5 #include <dballe/memdb/index.h>
6 #include <dballe/memdb/valuebase.h>
7 #include <wreport/var.h>
8 #include <memory>
9 
10 namespace dballe {
11 struct Record;
12 
13 namespace core {
14 struct Query;
15 }
16 
17 namespace msg {
18 struct Context;
19 }
20 
21 namespace memdb {
22 template<typename T> struct Results;
23 
24 struct Station;
25 
27 struct StationValue : public ValueBase
28 {
29  const Station& station;
30 
31  StationValue(const Station& station, std::unique_ptr<wreport::Var> var)
32  : ValueBase(std::move(var)), station(station) {}
33  ~StationValue();
34 
35 private:
36  StationValue(const StationValue&);
37  StationValue& operator=(const StationValue&);
38 };
39 
41 class StationValues : public ValueStorage<StationValue>
42 {
43 protected:
44  Index<const Station*> by_station;
45 
46 public:
47  void clear();
48 
49  bool has_variables_for(const Station& station) const
50  {
51  return by_station.find(&station) != by_station.end();
52  }
53 
54  const StationValue* get(const Station& station, wreport::Varcode code) const;
55 
57  size_t insert(const Station& station, std::unique_ptr<wreport::Var> var, bool replace=true);
58 
60  size_t insert(const Station& station, const wreport::Var& var, bool replace=true);
61 
67  bool remove(const Station& station, wreport::Varcode code);
68 
70  void erase(size_t idx);
71 
73  void fill_record(const Station& station, Record& rec) const;
74 
76  void fill_msg(const Station& station, msg::Context& ctx) const;
77 
79  void query(const core::Query& q, Results<Station>& stations, Results<StationValue>& res) const;
80 
81  void dump(FILE* out) const;
82 };
83 
84 }
85 }
86 
87 #endif
88 
89 
Store an array of physical data all on the same level.
Definition: context.h:44
Station information.
Definition: valuebase.h:36
Definition: mem/cursor.h:14
Storage and index for station values.
Definition: stationvalue.h:41
Key/value store where keys are strings and values are wreport variables.
Definition: record.h:16
Standard dballe::Query implementation.
Definition: core/query.h:29
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
Station information.
Definition: memdb/station.h:27
Value describing one property of a station.
Definition: stationvalue.h:27
Index element positions based by one value.
Definition: index.h:41
Definition: memdb/levtr.h:16