libdballe  7.7
memdb/levtr.h
1 #ifndef DBA_MEMDB_LTR_H
2 #define DBA_MEMDB_LTR_H
3 
4 #include <dballe/memdb/valuestorage.h>
5 #include <dballe/memdb/index.h>
6 #include <dballe/core/defs.h>
7 
8 namespace dballe {
9 struct Record;
10 
11 namespace core {
12 struct Query;
13 }
14 
15 namespace memdb {
16 template<typename T> struct Results;
17 
19 struct LevTr
20 {
21  Level level;
22  Trange trange;
23 
24  LevTr(const Level& level, const Trange& trange)
25  : level(level), trange(trange) {}
26 
27  bool operator<(const LevTr& o) const { return compare(o) < 0; }
28  bool operator>(const LevTr& o) const { return compare(o) > 0; }
29  bool operator==(const LevTr& o) const { return level == o.level && trange == o.trange; }
30  bool operator!=(const LevTr& o) const { return level != o.level || trange != o.trange; }
31 
38  int compare(const LevTr& o) const
39  {
40  if (int res = level.compare(o.level)) return res;
41  return trange.compare(o.trange);
42  }
43 };
44 
46 class LevTrs : public ValueStorage<LevTr>
47 {
48 protected:
49  Index<Level> by_level;
50  Index<Trange> by_trange;
51 
52 public:
53  LevTrs();
54 
55  void clear();
56 
58  size_t obtain(const Level& level, const Trange& trange);
59 
61  size_t obtain(const Record& rec);
62 
64  void query(const core::Query& q, Results<LevTr>& res) const;
65 
66  void dump(FILE* out) const;
67 };
68 
69 }
70 }
71 
72 #endif
73 
Aggregated level and time range information.
Definition: memdb/levtr.h:19
Definition: mem/cursor.h:14
int compare(const LevTr &o) const
Compare two LevTr strutures, for use in sorting.
Definition: memdb/levtr.h:38
Storage and index for level and time range aggregate sets.
Definition: memdb/levtr.h:46
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:565
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
Vertical level or layer.
Definition: types.h:515
int compare(const Level &l) const
Generic comparison.
int compare(const Trange &t) const
Generic comparison.
Index element positions based by one value.
Definition: index.h:41
Common definitions.
Definition: memdb/levtr.h:16