Andrea Blankenstijn
a19d2ea6bd
- mark as const every pointer that can be const. - in implementation mark const args passed by value that are meant to be read-only. - wrap in a lambda complex initializations of (const) values. - argument passing: - pass by value arguments of cheap-to-copy types or meant to be copied anyway. - pass by (const) reference args not meant to outlive called function scope and not cheap-to-copy. - pass (const) pointers to (const) args when null is a valid option and pointed data aren't expected to outlive function scope. - use string_view for non-owned strings (not meant to outlive function scope). - use span for collection types like vector and arrays. - fancy pointers passing: - pass by value if a reference will be held: - pass by const reference if a reference _may_ be hell. - when no references are meant to be held: - dereference the pointer to pass the pointed data by reference if null is not an option. - pass the underlying raw pointer if null is an option. … and random subtle changes and fixes here and there that I forgot to mention.
25 lines
586 B
C++
25 lines
586 B
C++
#ifndef BWIDGETS_EVENT_HANDLER_IMPL_HPP
|
|
#define BWIDGETS_EVENT_HANDLER_IMPL_HPP
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <basic_widgets/w/feat/event_handler.hpp>
|
|
|
|
namespace bwidgets
|
|
{
|
|
class EventHandlerImpl : public virtual EventHandler
|
|
{
|
|
std::unordered_map<SDL_EventType, std::function<void(const SDL_Event&)>>
|
|
_event_handlers {};
|
|
|
|
public:
|
|
void handle_event(const SDL_Event&) override;
|
|
|
|
protected:
|
|
auto _add_event_handler(handler_t) -> bool;
|
|
auto _remove_event_handler(SDL_EventType) -> std::pair<handler_t, bool>;
|
|
};
|
|
}
|
|
|
|
#endif
|