// // Application.hpp // libscgui // // Created by Bob Polis at 2020-10-23 // Copyright (c) 2020 SwiftCoder. All rights reserved. // #ifndef _Application_H_ #define _Application_H_ #include #include #include namespace sc { namespace gui { using EventHandler = bool(*)(const SDL_Event&); class Application { public: static Application& instance() { return app; } Application() = default; ~Application() = default; // prohibit copying and moving Application(const Application&) = delete; Application& operator=(const Application&) = delete; Application(Application&&) = delete; Application& operator=(Application&&) = delete; void run(); void add_event_handler(EventHandler handler, SDL_EventType event); private: static Application app; std::map> _event_handlers; bool handle_event(const SDL_Event& event); }; // convenience function Application& app() { return Application::instance(); } } } #endif // _Application_H_