Sming Framework API
()
Toggle main menu visibility
Sming
Libraries
rbpf
src
include
rbpf
common
rbpf/common/Store.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <stdint.h>
4
5
namespace
rBPF
6
{
7
class
Store
8
{
9
public
:
10
using
Key
= uint32_t;
11
using
Value
= uint32_t;
12
13
class
Entry
14
{
15
public
:
16
explicit
operator
bool()
const
17
{
18
return
valid;
19
}
20
21
Entry
&
operator=
(
Value
value)
22
{
23
valid = store.
update
(key, value);
24
return
*
this
;
25
}
26
27
operator
Value
()
const
28
{
29
return
store.
get
(key);
30
}
31
32
private
:
33
friend
Store
;
34
35
Entry
(
Store
& store,
Key
key) : store(store),
key
(
key
)
36
{
37
}
38
39
Store
& store;
40
Key
key;
41
bool
valid;
42
};
43
50
virtual
bool
update
(
Key
key
,
Value
value) = 0;
51
60
virtual
bool
fetch
(
Key
key
,
Value
& value) = 0;
61
66
Value
get
(
Key
key
)
67
{
68
Value
res;
69
fetch
(
key
, res);
70
return
res;
71
}
72
73
Entry
operator[]
(
Key
key
)
74
{
75
return
Entry
(*
this
,
key
);
76
}
77
};
78
79
}
// namespace rBPF
key
void size_t const void * key
Definition:
blake2s.h:33
rBPF::Store::Entry
Definition:
rbpf/common/Store.h:14
rBPF::Store::Entry::operator=
Entry & operator=(Value value)
Definition:
rbpf/common/Store.h:21
rBPF::Store
Definition:
rbpf/common/Store.h:8
rBPF::Store::update
virtual bool update(Key key, Value value)=0
Update value in store.
rBPF::Store::Key
uint32_t Key
Definition:
rbpf/common/Store.h:10
rBPF::Store::fetch
virtual bool fetch(Key key, Value &value)=0
Fetch value from store.
rBPF::Store::operator[]
Entry operator[](Key key)
Definition:
rbpf/common/Store.h:73
rBPF::Store::Value
uint32_t Value
Definition:
rbpf/common/Store.h:11
rBPF::Store::get
Value get(Key key)
Fetch value from store.
Definition:
rbpf/common/Store.h:66
rBPF
Definition:
bpf/rbpf/Store.h:7
Generated by
1.9.1