2005-06-28 01:04:34 +02:00
|
|
|
#include "../Messages.h"
|
|
|
|
|
|
|
|
namespace AtlasMessage
|
|
|
|
{
|
|
|
|
|
2005-07-03 18:25:48 +02:00
|
|
|
// (Random note: Be careful not to give handler .cpp files the same name
|
|
|
|
// as any other file in the project, because it makes everything very confused)
|
|
|
|
|
2005-08-20 17:44:50 +02:00
|
|
|
typedef void (*msgHandler)(IMessage*);
|
|
|
|
typedef std::map<std::string, msgHandler> msgHandlers;
|
|
|
|
extern msgHandlers& GetMsgHandlers();
|
2005-06-28 01:04:34 +02:00
|
|
|
|
|
|
|
#define CAT1(a,b) a##b
|
|
|
|
#define CAT2(a,b) CAT1(a,b)
|
|
|
|
|
|
|
|
#define REGISTER(t) namespace CAT2(hndlr_, __LINE__) { struct init { init() { \
|
2005-08-20 17:44:50 +02:00
|
|
|
bool notAlreadyRegisted = GetMsgHandlers().insert(std::pair<std::string, msgHandler>(#t, &f##t)).second; \
|
2005-06-28 01:04:34 +02:00
|
|
|
assert(notAlreadyRegisted); \
|
|
|
|
} } init; };
|
|
|
|
|
2005-07-03 18:25:48 +02:00
|
|
|
}
|