21 #ifndef GF_MESSAGE_MANAGER_H
22 #define GF_MESSAGE_MANAGER_H
26 #include <initializer_list>
28 #include <type_traits>
35 #ifndef DOXYGEN_SHOULD_SKIP_THIS
45 using MessageHandlerId = uint64_t;
131 return registerHandler(E::type, handler);
161 template<
typename R,
typename T>
163 return registerHandler(type, std::bind(pm, obj, std::placeholders::_1, std::placeholders::_2));
192 template<
typename E,
typename R,
typename T>
196 return registerHandler(E::type, std::bind(pm, obj, std::placeholders::_1, std::placeholders::_2));
219 for (
auto id : ids) {
282 sendMessage(E::type, message);
290 MessageHandler handler;
293 MessageHandlerId m_currentId;
294 std::map<Id, std::vector<Handler>> m_handlers;
297 #ifndef DOXYGEN_SHOULD_SKIP_THIS
MessageHandlerId registerHandler(MessageHandler handler)
Register a message handler for a type of message.
Definition: MessageManager.h:128
void sendMessage(E *message)
Send a message.
Definition: MessageManager.h:279
friend class RenderTarget
Definition: Shader.h:387
A message manager.
Definition: MessageManager.h:76
MessageHandlerId registerHandler(R T::*pm, T *obj)
Register a message handler for a type of message.
Definition: MessageManager.h:193
MessageHandlerId registerHandler(Id type, MessageHandler handler)
Register a message handler for a type of message.
MessageHandlerId registerHandler(Id type, R T::*pm, T *obj)
Register a message handler for a type of message.
Definition: MessageManager.h:162
The base class for all messages.
Definition: Message.h:53
MessageManager()
Constructor.
void removeHandlers(std::initializer_list< MessageHandlerId > ids)
Remove a list of handlers.
Definition: MessageManager.h:218
#define GF_API
Definition: Portability.h:35
void removeHandler(MessageHandlerId id)
Remove a handler.
void sendMessage(Id type, Message *message)
Send a message.