|
Thunderbots Project
|
#include <observer.hpp>

Public Member Functions | |
| Observer (size_t buffer_size=DEFAULT_BUFFER_SIZE, bool log_buffer_full=true) | |
| virtual void | receiveValue (T val) |
| virtual double | getDataReceivedPerSecond () final |
Static Public Attributes | |
| static constexpr size_t | TIME_BUFFER_SIZE = 5 |
Protected Member Functions | |
| virtual std::optional< T > | popMostRecentlyReceivedValue (Duration max_wait_time) final |
| virtual std::optional< T > | popLeastRecentlyReceivedValue (Duration max_wait_time) final |
Static Protected Attributes | |
| static constexpr size_t | DEFAULT_BUFFER_SIZE = 1 |
This class observes an "Subject<T>". That is, it can be registered with an "Subject<T>" to receive new instances of type T when they are available
| T | The type of object this class is observing |
| Clock | A clock that satisfies the TrivialClock requirements |
| Observer | ( | size_t | buffer_size = DEFAULT_BUFFER_SIZE, |
| bool | log_buffer_full = true |
||
| ) |
Creates a new Observer
| buffer_size | size of the buffer |
| log_buffer_full | whether or not to log when the buffer is full |
|
finalvirtual |
Calculate the data received per second using the internal time buffer
|
finalprotectedvirtual |
Pops the least recently received value and returns it
If no value is available, this will block until:
| max_wait_time | The maximum duration to wait for a new value before returning |
|
finalprotectedvirtual |
Pops the most recently received value and returns it
If no value is available, this will block until:
| max_wait_time | The maximum duration to wait for a new value before returning |
|
virtual |
Add the given value to the internal buffer
| val | The value to add to the internal buffer |