libdballe
9.9
dballe
db
v7
cache.h
1
#ifndef DBALLE_DB_V7_CACHE_H
2
#define DBALLE_DB_V7_CACHE_H
3
4
#include <
dballe/types.h
>
5
#include <unordered_map>
6
#include <memory>
7
#include <vector>
8
#include <iosfwd>
9
10
namespace
dballe {
11
namespace
db {
12
namespace
v7 {
13
14
struct
LevTrEntry
15
{
16
// Database ID
17
int
id
= MISSING_INT;
18
20
Level
level
;
21
23
Trange
trange
;
24
25
LevTrEntry
() =
default
;
26
LevTrEntry
(
int
id
,
const
Level
&
level
,
const
Trange
&
trange
) : id(id),
level
(
level
),
trange
(
trange
) {}
27
LevTrEntry
(
const
Level
&
level
,
const
Trange
&
trange
) :
level
(
level
),
trange
(
trange
) {}
28
LevTrEntry(
const
LevTrEntry&) =
default
;
29
LevTrEntry(LevTrEntry&&) =
default
;
30
LevTrEntry& operator=(
const
LevTrEntry&) =
default
;
31
LevTrEntry& operator=(LevTrEntry&&) =
default
;
32
33
bool
operator==(
const
LevTrEntry& o)
const
;
34
bool
operator!=(
const
LevTrEntry& o)
const
;
35
};
36
37
std::ostream& operator<<(std::ostream&,
const
LevTrEntry&);
38
39
struct
LevTrReverseIndex
:
public
std::unordered_map<Level, std::vector<const LevTrEntry*>>
40
{
41
int
find_id(
const
LevTrEntry
&
st
)
const
;
42
void
add(
const
LevTrEntry
*
st
);
43
};
44
45
46
struct
LevTrCache
47
{
48
std::unordered_map<int, LevTrEntry*> by_id;
49
LevTrReverseIndex
reverse;
50
51
LevTrCache
() =
default
;
52
LevTrCache
(
const
LevTrCache
&) =
delete
;
53
LevTrCache
(
LevTrCache
&&) =
delete
;
54
LevTrCache
& operator=(
const
LevTrCache
&) =
delete
;
55
LevTrCache
& operator=(
LevTrCache
&&) =
delete
;
56
~LevTrCache
();
57
58
const
LevTrEntry
* find_entry(
int
id
)
const
;
59
60
const
LevTrEntry
* insert(
const
LevTrEntry
&
e
);
61
const
LevTrEntry
* insert(
const
LevTrEntry
&
e
,
int
id
);
62
const
LevTrEntry
* insert(std::unique_ptr<LevTrEntry>
e
);
63
64
int
find_id(
const
LevTrEntry
&
e
)
const
;
65
66
void
clear();
67
};
68
69
}
70
}
71
}
72
73
#endif
dballe::db::v7::Tracer
Smart pointer for trace::Step objects, which calls done() when going out of scope.
Definition
db/v7/fwd.h:46
dballe::Level
Vertical level or layer.
Definition
types.h:625
dballe::Trange
Information on how a value has been sampled or computed with regards to time.
Definition
types.h:687
dballe::db::v7::LevTrCache
Definition
cache.h:47
dballe::db::v7::LevTrEntry
Definition
cache.h:15
dballe::db::v7::LevTrEntry::trange
Trange trange
Time range.
Definition
cache.h:23
dballe::db::v7::LevTrEntry::level
Level level
Vertical level or layer.
Definition
cache.h:20
dballe::db::v7::LevTrReverseIndex
Definition
cache.h:40
types.h
Common base types used by most of DB-All.e code.
Generated by
1.10.0