Elma
An event loop manager for embedded systems
src
channel.cc
1
#include <iostream>
2
#include <stdexcept>
3
#include "elma.h"
4
5
namespace
elma
{
6
10
Channel
&
Channel::send
(json value) {
11
_queue.push_front(value);
12
while
( _queue.size() >
capacity
() ) {
13
_queue.pop_back();
14
}
15
return
*
this
;
16
}
17
20
Channel
&
Channel::flush
() {
21
_queue.clear();
22
return
*
this
;
23
}
24
28
json
Channel::latest
() {
29
if
( _queue.size() == 0 ) {
30
throw
Exception
(
"Tried to get the latest value in an empty channel."
);
31
}
32
return
_queue.front();
33
}
34
38
json
Channel::earliest
() {
39
if
( _queue.size() == 0 ) {
40
throw
Exception
(
"Tried to get the earliest value in an empty channel."
);
41
}
42
return
_queue.back();
43
}
44
45
}
elma::Channel::latest
json latest()
Definition:
channel.cc:28
elma::Channel::flush
Channel & flush()
Definition:
channel.cc:20
elma::Channel::earliest
json earliest()
Definition:
channel.cc:38
elma::Channel::send
Channel & send(json)
Definition:
channel.cc:10
elma::Exception
An exception class for Elma.
Definition:
exceptions.h:13
elma::Channel
A channel for sending double values to and from Process objects.
Definition:
channel.h:21
elma
Definition:
channel.cc:5
elma::Channel::capacity
int capacity()
Definition:
channel.h:57
Developed by
Eric Klavins
for UW ECE P 520
Generated on Sun Mar 8 2020 16:45:58 for Elma by
Doxygen
1.8.13