The Process Manager class. More...
#include <manager.h>
Public Member Functions | |
Manager () | |
Default constructor. | |
Manager & | schedule (Process &process, high_resolution_clock::duration period) |
Manager & | all (std::function< void(Process &)> f) |
Manager & | init () |
Manager & | start () |
Manager & | update () |
Manager & | stop () |
Manager & | run (high_resolution_clock::duration) |
high_resolution_clock::time_point | start_time () |
high_resolution_clock::duration | elapsed () |
Manager & | add_channel (Channel &) |
Channel & | channel (string) |
Manager & | watch (string event_name, std::function< void(Event &)> handler) |
Manager & | emit (const Event &event) |
Client & | client () |
Example usage:
Add a channel to the manager
The | channel to be added |
Definition at line 26 of file manager.cc.
Apply a function to all processes.
f | The function to apply. It should take a reference to a process and return void. |
Definition at line 83 of file manager.cc.
Channel & elma::Manager::channel | ( | string | name | ) |
Retrieve a reference to an existing channel. Throws an error if no such channel exists.
Definition at line 33 of file manager.cc.
|
inline |
Emit an event associated with a name. Typically, a process would emit events in its update() method using something like the following code"
where value is any jsonable value. For example, you can write
event | The Event to be emitted |
Definition at line 68 of file manager.cc.
Manager & elma::Manager::init | ( | ) |
Initialize all processes. Usually called before run()
Definition at line 92 of file manager.cc.
Manager & elma::Manager::run | ( | high_resolution_clock::duration | runtime | ) |
Run the manager for the specified amount of time.
The | desired amount of time to run |
Definition at line 122 of file manager.cc.
Add a Process to the manager, to be run at a certain frequency.
process | The process to be scheduled, usually derived from the Process abstract base class |
period | The desired duration of time between updates |
Definition at line 11 of file manager.cc.
Manager & elma::Manager::start | ( | ) |
Start all processes. Usually not called directly.
Definition at line 98 of file manager.cc.
|
inline |
Manager & elma::Manager::stop | ( | ) |
Stop all processes. Usually not called directly.
Definition at line 104 of file manager.cc.
Manager & elma::Manager::update | ( | ) |
Update all processes if enough time has passed. Usually not called directly.
Definition at line 110 of file manager.cc.
Watch for an event associated with the given name. For watching events, you would typically register event handlers in your process' init() method. For example,
event_name | The name of the event A function or lambda that takes an event and returns nothing. |
Definition at line 51 of file manager.cc.