8#ifndef __HANDLERCHAIN_CLASS_H__
9#define __HANDLERCHAIN_CLASS_H__
18#include "helpers/formatstring.h"
104 std::list<IMessageHandler::shared_ptr_t> copyof_MessageHandlers(
_messageHandlers.size());
112 if (window->ProcessMessage(message))
132 std::list<IMessageHandler::shared_ptr_t>::iterator foundIter;
181 std::ostringstream output;
183 std::list<IMessageHandler::shared_ptr_t> copyof_MessageHandlers(
_messageHandlers.size());
Represents a list of handlers that all implement the IMessageHandler interface. This list can be dyna...
void SendMessage(Message *message)
Send a message to each of the handlers in the list, protected by a multi-threading lock.
std::string ToString()
Convert this HandlerChain to a string, protected by a multi-threading lock.
std::unique_ptr< HandlerChain > unique_ptr_t
std::list< IMessageHandler::shared_ptr_t > _messageHandlers
The list of message handlers.
std::mutex _messageHandlersLock
Object used to lock access to the message handlers list for multi-threaded support.
void AddHandler(IMessageHandler::shared_ptr_t window)
Add an instance of the IMessageHandler interface to end of the list of handlers, protected by a multi...
void RemoveHandler(IMessageHandler *window)
Remove an instance of the IMessageHandler interface from the list, protected by a multi-threading loc...
void RemoveHandler(IMessageHandler::shared_ptr_t window)
Remove an instance of the IMessageHandler interface from the list, protected by a multi-threading loc...
The namespace containing all Design Pattern Examples implemented in C++.
std::string formatstring(const char *fmt,...)
Use the given string and arguments to return a buffer containing the formatted string....
Represents a handler in a chain of handlers. All objects that participate in the HandlerChain class m...
virtual int ID()=0
ID of the window. This is used to uniquely identify a window in the collection.
virtual std::string ToString()=0
Convert the handler to a string.
std::shared_ptr< IMessageHandler > shared_ptr_t
Alias to make it easier when using a shared pointer.
virtual bool ProcessMessage(Message *message)=0
Called with a message on each window.
virtual ~IMessageHandler()
Virtual destructor (required for interfaces in C++)
Represents a message sent to the windows. A message contains a type and a position.
Represents a message sent to the windows. A message contains a type and a position.