Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Event_Queue
- {
- private:
- SDL_Event input;
- std::queue<Event> event_queue;
- std::vector<Event_Receiver*> receiver_list;
- public:
- void add_receiver(Event_Receiver* receiver_ptr);
- bool remove_receiver(Event_Receiver* receiver_ptr);
- void push_event(Event e);
- void poll_input();
- void poll_event();
- };
- class Event_Receivable
- {
- public:
- virtual ~Event_Receivable() = 0;
- virtual void on_notify(Event* e) = 0;
- };
- class Event_Receiver
- {
- public:
- Event_Receiver(Event_Receivable* owner_obj);
- ~Event_Receiver();
- void receive_event(Event* e);
- void notify_owner(Event* e);
- void set_owner(Event_Receivable* owner_obj) {owner = owner_obj;}
- Event_Receivable* get_owner_obj() {return owner;}
- private:
- Event_Receivable* owner;
- };
- #include "Common.h"
- #include "boost/any.hpp"
- /*
- * Event is used extensively within the program.
- * It is the basis for all messages in the event system.
- * Objects will send and receive events.
- *
- * It uses boost::any in order to be able to
- * attach any kind of data to be read.
- *
- * Event is meant to be extremely flexible in order to
- * be extensible to many different types of games.
- */
- class Event
- {
- private:
- std::string name;
- std::string type;
- std::vector<boost::any> info;
- public:
- Event(std::string name_str, std::string type_str)
- {
- name = name_str;
- type = type_str;
- }
- void set_name(std::string str) {name = str;}
- void set_type(std::string str) {type = str;}
- void attach_data(boost::any data) {info.push_back(data);}
- std::string get_name() {return name;}
- std::string get_type() {return type;}
- boost::any get_info() {return info;}
- };
- class Event_Sender
- {
- public:
- void send_event(Event e);
- void send_event(Event e, Event_Queue q);
- void set_event_queue(Event_Queue e_queue) {event_queue = &e_queue;}
- Event_Queue* get_event_queue() {return event_queue;}
- private:
- Event_Queue* event_queue;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement