|
Thunderbots Project
|
#include <observer_subject_adapter.hpp>


Public Types | |
| using | ConversionFunctionType = SubjectType(const ObserverType &) |
Public Member Functions | |
| ObserverSubjectAdapter (std::function< ConversionFunctionType > conversion_function_) | |
| virtual void | receiveValue (ObserverType val) final |
Public Member Functions inherited from Observer< ObserverType > | |
| Observer (size_t buffer_size=DEFAULT_BUFFER_SIZE, bool log_buffer_full=true) | |
| virtual void | receiveValue (ObserverType val) |
| virtual double | getDataReceivedPerSecond () final |
Public Member Functions inherited from Subject< SubjectType > | |
| void | registerObserver (std::shared_ptr< Observer< SubjectType > > observer) |
Additional Inherited Members | |
Static Public Attributes inherited from Observer< ObserverType > | |
| static constexpr size_t | TIME_BUFFER_SIZE |
Protected Member Functions inherited from Observer< ObserverType > | |
| virtual std::optional< ObserverType > | popMostRecentlyReceivedValue (Duration max_wait_time) final |
| virtual std::optional< ObserverType > | popLeastRecentlyReceivedValue (Duration max_wait_time) final |
Protected Member Functions inherited from Subject< SubjectType > | |
| virtual void | sendValueToObservers (SubjectType val) final |
Static Protected Attributes inherited from Observer< ObserverType > | |
| static constexpr size_t | DEFAULT_BUFFER_SIZE |
ObserverSubjectAdapter is a class made to "adapt" a type emitted by a Subject to a different type consumed by an Observer with a conversion function passed in the constructor.
Based on the Adapter design pattern described here: https://refactoring.guru/design-patterns/adapter
| ObserverType | The type that this class observes, i.e. converted-from type |
| SubjectType | The type that this class is a subject of, i.e. converted-to type |
|
inlineexplicit |
Constructs an ObserverSubjectAdapter with the given conversion function that consumes a const-ref of the observed type and returns the subject type.
| conversion_function_ | A function that converts ObserverType to SubjectType. |
|
finalvirtual |
Receives a value, calls the conversion function on it, and sends it to the Observers of this object.
| val | a value |