#include "../Messages.h" namespace AtlasMessage { // (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) typedef void (*handler)(IMessage*); typedef std::map handlers; extern handlers& GetHandlers(); #define CAT1(a,b) a##b #define CAT2(a,b) CAT1(a,b) #define REGISTER(t) namespace CAT2(hndlr_, __LINE__) { struct init { init() { \ bool notAlreadyRegisted = GetHandlers().insert(std::pair(#t, &f##t)).second; \ assert(notAlreadyRegisted); \ } } init; }; }