1 #ifndef _ELMA_PROCESS_H 2 #define _ELMA_PROCESS_H 35 Process(
int n = 0) : _name(
"unnamed process"), _status(UNINITIALIZED), _manager_ptr(NULL), _priority(n) {}
41 Process(std::string name,
int n = 0) : _name(name), _status(UNINITIALIZED), _manager_ptr(NULL), _priority(n) {}
50 virtual void init() = 0;
55 virtual void start() = 0;
61 virtual void update() = 0;
66 virtual void stop() = 0;
72 inline string name() {
return _name; }
76 inline void set_name(std::string str) { _name = str; }
80 inline status_type
status() {
return _status; }
84 inline high_resolution_clock::duration
period() {
return _period; }
92 inline time_point<high_resolution_clock>
start_time() {
return _start_time; }
97 inline high_resolution_clock::duration
last_update() {
return _last_update; }
109 void watch(
string event_name, std::function<
void(
Event&)> handler);
110 void emit(
const Event& event);
112 void http_get(std::string url, std::function<
void(json&)> handler);
116 void set_manager(
Manager * m_ptr);
122 void _start(high_resolution_clock::duration elapsed);
123 void _update(high_resolution_clock::duration elapsed);
129 high_resolution_clock::duration _period,
132 time_point<high_resolution_clock> _start_time;
133 int _num_updates, _priority;
The Process Manager class.
Process(std::string name, int n=0)
Constructor that takes a name for the process.
high_resolution_clock::duration previous_update()
time_point< high_resolution_clock > start_time()
Process(int n=0)
Default constructor. Names process "no name".
Events that can be emitted, watched, and responded to with event handlers.
high_resolution_clock::duration last_update()
high_resolution_clock::duration period()
A channel for sending double values to and from Process objects.
void set_name(std::string str)
An abstract base class for processes.