Nebula
Loading...
Searching...
No Matches
staticmessagehandler.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
13#include "messaging/message.h"
14
15//------------------------------------------------------------------------------
16namespace Messaging
17{
19{
20public:
22 template<class OBJTYPE> static void Dispatch(const Ptr<OBJTYPE>& object, const Ptr<Message>& msg);
24 template<class OBJTYPE, class MSGTYPE> static void Handle(const Ptr<OBJTYPE>& object, const Ptr<MSGTYPE>& msg);
26 template<class MSGTYPE> static void Handle(const Ptr<MSGTYPE>& msg);
27};
28
29//------------------------------------------------------------------------------
32#define __Dispatch(OBJCLASS,OBJ,MSG) Messaging::StaticMessageHandler::Dispatch<OBJCLASS>(OBJ, MSG)
33#define __Dispatcher(OBJCLASS) template<> void Messaging::StaticMessageHandler::Dispatch(const Ptr<OBJCLASS>& obj, const Ptr<Messaging::Message>& msg)
34#define __Handle(OBJCLASS,MSGCLASS) if (msg->CheckId(MSGCLASS::Id)) { Messaging::StaticMessageHandler::Handle<OBJCLASS,MSGCLASS>(obj, msg.downcast<MSGCLASS>()); return; }
35#define __StaticHandle(MSGCLASS) if (msg->CheckId(MSGCLASS::Id)) { Messaging::StaticMessageHandler::Handle<MSGCLASS>(msg.downcast<MSGCLASS>()); return true; }
36#define __HandleByRTTI(OBJCLASS,MSGCLASS) if (msg->IsA(MSGCLASS::RTTI)) { Messaging::StaticMessageHandler::Handle<OBJCLASS,MSGCLASS>(obj, msg.downcast<MSGCLASS>()); return; }
37#define __HandleUnknown(SUPERCLASS) { Messaging::StaticMessageHandler::Dispatch<SUPERCLASS>(obj.upcast<SUPERCLASS>(), msg); }
38#define __Handler(OBJCLASS,MSGCLASS) template<> void Messaging::StaticMessageHandler::Handle<OBJCLASS,MSGCLASS>(const Ptr<OBJCLASS>& obj, const Ptr<MSGCLASS>& msg)
39#define __StaticHandler(MSGCLASS) template<> void Messaging::StaticMessageHandler::Handle<MSGCLASS>(const Ptr<MSGCLASS>& msg)
40
41// sends message to interface
42#define __StaticSend(INTERFACECLASS, MSG) INTERFACECLASS::Instance()->Send(MSG.downcast<Messaging::Message>())
43#define __StaticSendWait(INTERFACECLASS, MSG) INTERFACECLASS::Instance()->SendWait(MSG.downcast<Messaging::Message>())
44
45// sends message to graphics entity
46#define __Send(OBJ, MSG) OBJ->Send(MSG.downcast<Graphics::GraphicsEntityMessage>())
47
48} // namespace Messaging
Implements a simple, static message handler helper class.
Definition staticmessagehandler.h:19
static void Dispatch(const Ptr< OBJTYPE > &object, const Ptr< Message > &msg)
dispatch a message to handling method
static void Handle(const Ptr< MSGTYPE > &msg)
a handler method without object association
static void Handle(const Ptr< OBJTYPE > &object, const Ptr< MSGTYPE > &msg)
a handler method with object association
Nebula's smart pointer class which manages the life time of RefCounted objects.
Definition ptr.h:38
Definition asyncport.cc:10