Loading [MathJax]/extensions/tex2jax.js
SensESP
3.1.0
Universal Signal K sensor toolkit ESP32
Toggle main menu visibility
Main Page
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
k
m
n
o
s
u
v
w
Functions
a
b
c
e
f
g
h
m
o
s
u
Variables
Typedefs
a
b
d
f
i
n
s
v
w
Enumerations
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
z
~
Functions
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
z
~
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
y
Typedefs
Related Symbols
Files
File List
File Members
All
b
d
g
h
k
l
m
p
r
s
w
Functions
Variables
Macros
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Loading...
Searching...
No Matches
observable.h
Go to the documentation of this file.
1
#ifndef SENSESP_SYSTEM_OBSERVABLE_H
2
#define SENSESP_SYSTEM_OBSERVABLE_H
3
4
#include <forward_list>
5
#include <functional>
6
#include <vector>
7
8
namespace
sensesp
{
9
16
class
Observable
{
17
public
:
18
Observable
() {}
19
21
Observable
(
Observable
&& other) : observers_{other.observers_} {}
22
23
void
notify
() {
24
for
(
auto
o : observers_) {
25
o();
26
}
27
}
23
void
notify
() {
…
}
28
29
void
attach
(std::function<
void
()> observer) {
30
// First iterate to the last element
31
auto
before_end = observers_.before_begin();
32
for
(
auto
& _ : observers_) {
33
++before_end;
34
}
35
// Then insert the new observer
36
observers_.insert_after(before_end, observer);
37
}
29
void
attach
(std::function<
void
()> observer) {
…
}
38
39
private
:
40
std::forward_list<std::function<void()> > observers_;
41
};
16
class
Observable
{
…
};
42
43
}
// namespace sensesp
44
45
#endif
sensesp::Observable
A base class which allow observers to attach callbacks to themselves. The callbacks will be called wh...
Definition
observable.h:16
sensesp::Observable::Observable
Observable(Observable &&other)
Move constructor.
Definition
observable.h:21
sensesp::Observable::attach
void attach(std::function< void()> observer)
Definition
observable.h:29
sensesp::Observable::Observable
Observable()
Definition
observable.h:18
sensesp::Observable::notify
void notify()
Definition
observable.h:23
sensesp
Definition
sensesp.cpp:7
src
sensesp
system
observable.h
Generated by
1.12.0