template<class M>
struct Message_ : Message
{
Message_(void)
{
}
static bool checkType(Message* message)
{
return Message_<M>::getID_static() == message->getID() ? true : false;
}
static M* convert(Message* message)
{
if (Message_<M>::getID_static() == message->getID())
return (M*)message;
return NULL;
}
virtual const int getID(void) const
{
return Message_<M>::getID_static();
}
static int getID_static(void)
{
if (Message_<M>::TypeIDRef_Custom == -1)
return (int)&Message_<M>::TypeIDRef;
return Message_<M>::TypeIDRef_Custom;
}
static void setID_static(int id)
{
Message_<M>::TypeIDRef_Custom = id;
}
private:
static const int TypeIDRef;
static int TypeIDRef_Custom;
};
dGVtcGxhdGU8Y2xhc3MgTT4Kc3RydWN0IE1lc3NhZ2VfIDogTWVzc2FnZQp7CiAgICBNZXNzYWdlXyh2b2lkKQogICAgewogICAgfQogICAgc3RhdGljIGJvb2wgY2hlY2tUeXBlKE1lc3NhZ2UqIG1lc3NhZ2UpCiAgICB7CiAgICAgICAgcmV0dXJuIE1lc3NhZ2VfPE0+OjpnZXRJRF9zdGF0aWMoKSA9PSBtZXNzYWdlLT5nZXRJRCgpID8gdHJ1ZSA6IGZhbHNlOwogICAgfQogICAgc3RhdGljIE0qIGNvbnZlcnQoTWVzc2FnZSogbWVzc2FnZSkKICAgIHsKICAgICAgICBpZiAoTWVzc2FnZV88TT46OmdldElEX3N0YXRpYygpID09IG1lc3NhZ2UtPmdldElEKCkpCiAgICAgICAgICAgIHJldHVybiAoTSopbWVzc2FnZTsKICAgICAgICByZXR1cm4gTlVMTDsKICAgIH0KICAgIHZpcnR1YWwgY29uc3QgaW50IGdldElEKHZvaWQpIGNvbnN0CiAgICB7CiAgICAgICAgcmV0dXJuIE1lc3NhZ2VfPE0+OjpnZXRJRF9zdGF0aWMoKTsKICAgIH0KICAgIHN0YXRpYyBpbnQgZ2V0SURfc3RhdGljKHZvaWQpCiAgICB7CiAgICAgICAgaWYgKE1lc3NhZ2VfPE0+OjpUeXBlSURSZWZfQ3VzdG9tID09IC0xKQogICAgICAgICAgICByZXR1cm4gK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