12 if ( _manager_ptr == NULL ) {
13 throw Exception(
"Cannot access channels in a process before the process is scheduled.");
15 return _manager_ptr->
channel(name);
19 void Process::watch(
string event_name, std::function<
void(
Event&)> handler) {
20 if ( _manager_ptr == NULL ) {
21 throw Exception(
"Cannot access events in a process before the process is scheduled.");
23 _manager_ptr->
watch(event_name, handler);
27 void Process::emit(
const Event& event) {
28 if ( _manager_ptr == NULL ) {
29 throw Exception(
"Cannot access events in a process before the process is scheduled.");
31 _manager_ptr->
emit(event);
35 void Process::http_get(std::string url, std::function<
void(json&)> handler) {
36 _manager_ptr->client().
get(url,handler);
60 void Process::_init() {
65 void Process::_start(high_resolution_clock::duration elapsed) {
67 _start_time = high_resolution_clock::now();
68 _last_update = elapsed;
74 void Process::_update(high_resolution_clock::duration elapsed) {
75 _previous_update = _last_update;
76 _last_update = elapsed;
82 void Process::_stop() {
87 void Process::halt() { _manager_ptr->
stop(); }
89 void Process::set_manager(
Manager * m_ptr) {
90 if ( _manager_ptr == NULL ) {
93 throw Exception(
"A process cannot have two managers");
The Process Manager class.
Channel & channel(string name)
Access a channel with the given name.
high_resolution_clock::duration previous_update()
Channel & channel(string)
Manager & watch(string event_name, std::function< void(Event &)> handler)
Events that can be emitted, watched, and responded to with event handlers.
high_resolution_clock::duration last_update()
double milli_time()
The time since the last update in millisconds, as a double.
An exception class for Elma.
Client & get(std::string url, std::function< void(json &)> handler)
double delta()
The most recent amount of time between updates.
A channel for sending double values to and from Process objects.
Manager & emit(const Event &event)