Building the event manager
At this time, we have everything we need to actually write the header of our event manager class. Given all the design decisions we made previously, it should come out looking something like the following:
class EventManager{ public: EventManager(); ~EventManager(); bool AddBinding(Binding *l_binding); bool RemoveBinding(std::string l_name); void SetFocus(const bool& l_focus); // Needs to be defined in the header! template<class T> bool AddCallback(const std::string& l_name, void(T::*l_func)(EventDetails*), T* l_instance) { auto temp = std::bind(l_func,l_instance, std::placeholders::_1); return m_callbacks.emplace(l_name, temp).second; } void RemoveCallback(const std::string& l_name){ m_callbacks.erase(l_name); } void ...
Get SFML Game Development By Example now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.