19 #include "eventserver.h"
20 #include "eventexceptions.h"
26 const std::string event1=
"event_1";
31 const std::string event2=
"event_2";
36 const std::string event3=
"invalid_event";
85 int main(
int argc,
char *argv[])
88 std::list<std::string> events;
95 events.push_back(event1);
96 events.push_back(event2);
98 std::cout <<
"Activate event 1" << std::endl;
100 std::cout <<
"Activate event 2" << std::endl;
104 std::cout <<
"Reset event 1" << std::endl;
107 std::cout <<
"Wait for the first event to get active ... " << std::endl;
109 std::cout << event_id << std::endl;
111 std::cout <<
"event 1 is set" << std::endl;
113 std::cout <<
"event 1 is not set" << std::endl;
115 std::cout <<
"event 2 is set" << std::endl;
117 std::cout <<
"event 2 is not set" << std::endl;
118 std::cout <<
"Activate event 1" << std::endl;
120 std::cout <<
"Activate event 2" << std::endl;
123 std::cout <<
"All events were active" << std::endl;
125 std::cout <<
"event 1 is set" << std::endl;
127 std::cout <<
"event 1 is not set" << std::endl;
129 std::cout <<
"event 2 is set" << std::endl;
131 std::cout <<
"event 2 is not set" << std::endl;
133 event_server->
wait_all(events,1000);
135 std::cout << e.
what() << std::endl;
137 std::cout << e.
what() << std::endl;
145 std::cout << e.
what() << std::endl;
void create_event(const std::string &event_id)
Function to create a new event.
void wait_all(std::list< std::string > events, int timeout=-1)
Function to wait for all the events is a set.
virtual const std::string & what(void)
Function to get the error message.
bool event_is_set(const std::string &event_id)
Function to query if the event is active or not.
Event timeout exception class.
Event server exception class.
int wait_first(std::list< std::string > events, int timeout=-1)
Function to wait for the first event in a set.
void delete_event(const std::string &event_id)
Function to delete an existing event.
void set_event(const std::string &event_id)
Function to activate an event.
static CEventServer * instance(void)
Function to get a reference to the unique instance.
void reset_event(const std::string &event_id)
Function to deactivate an event.