Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: plCreatable modernizing #520

Merged
merged 6 commits into from
Jan 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions Sources/Plasma/NucleusLib/inc/plgDispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class plKey;
class plDispatchBase : public plCreatable
{
public:
CLASSNAME_REGISTER( plDispatchBase );
GETINTERFACE_ANY( plDispatchBase, plCreatable );
CLASSNAME_REGISTER(plDispatchBase);
GETINTERFACE_ANY(plDispatchBase, plCreatable);

virtual void RegisterForType(uint16_t hClass, const plKey& receiver) = 0;
virtual void RegisterForExactType(uint16_t hClass, const plKey& receiver) = 0;
Expand All @@ -62,21 +62,30 @@ class plDispatchBase : public plCreatable

virtual void UnRegisterAll(const plKey& receiver) = 0;

virtual bool MsgSend(plMessage* msg, bool async=false) = 0;
virtual void MsgQueue(plMessage* msg)=0; // Used by other thread to Send Messages, they are handled as soon as Practicable
virtual void MsgQueueProcess() = 0;
virtual void MsgQueueOnOff(bool) = 0; // Turn on or off Queued Messages, if off, uses MsgSend Immediately (for plugins)
virtual bool MsgSend(plMessage* msg, bool async=false) = 0;

virtual bool SetMsgBuffering(bool on) = 0; // On starts deferring msg delivery until buffering is set to off again.
// Used by other thread to Send Messages, they are handled as soon as
// Practicable
virtual void MsgQueue(plMessage* msg)=0;
virtual void MsgQueueProcess() = 0;

virtual void BeginShutdown() = 0;
// Turn on or off Queued Messages, if off, uses MsgSend Immediately (for
// plugins)
virtual void MsgQueueOnOff(bool) = 0;

// On starts deferring msg delivery until buffering is set to off again.
virtual bool SetMsgBuffering(bool on) = 0;

virtual void BeginShutdown() = 0;
};

class plgDispatch
{
public:
static plDispatchBase* Dispatch();
static bool MsgSend(plMessage* msg, bool async = false) { return Dispatch()->MsgSend(msg, async); }
static bool MsgSend(plMessage* msg, bool async = false) {
return Dispatch()->MsgSend(msg, async);
}
};


Expand Down
51 changes: 30 additions & 21 deletions Sources/Plasma/NucleusLib/pnDispatch/plDispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,42 +118,51 @@ class plDispatch : public plDispatchBase
CLASSNAME_REGISTER( plDispatch );
GETINTERFACE_ANY( plDispatch, plCreatable );

virtual void RegisterForType(uint16_t hClass, const plKey& receiver);
virtual void RegisterForExactType(uint16_t hClass, const plKey& receiver);
void RegisterForType(uint16_t hClass, const plKey& receiver) HS_OVERRIDE;
void RegisterForExactType(uint16_t hClass, const plKey& receiver) HS_OVERRIDE;

virtual void UnRegisterForType(uint16_t hClass, const plKey& receiver);
virtual void UnRegisterForExactType(uint16_t hClass, const plKey& receiver);
void UnRegisterForType(uint16_t hClass, const plKey& receiver) HS_OVERRIDE;
void UnRegisterForExactType(uint16_t hClass, const plKey& receiver) HS_OVERRIDE;

virtual void UnRegisterAll(const plKey& receiver);
void UnRegisterAll(const plKey& receiver) HS_OVERRIDE;

virtual bool MsgSend(plMessage* msg, bool async=false);
virtual void MsgQueue(plMessage* msg); // Used by other thread to Send Messages, they are handled as soon as Practicable
virtual void MsgQueueProcess();
virtual void MsgQueueOnOff(bool ); // Turn on or off Queued Messages, if off, uses MsgSend Immediately
bool MsgSend(plMessage* msg, bool async=false) HS_OVERRIDE;

virtual bool SetMsgBuffering(bool on); // On starts deferring msg delivery until buffering is set to off again.
// Used by other thread to Send Messages, they are handled as soon as
// Practicable
void MsgQueue(plMessage* msg) HS_OVERRIDE;
void MsgQueueProcess() HS_OVERRIDE;

virtual void BeginShutdown();
// Turn on or off Queued Messages, if off, uses MsgSend Immediately (for
// plugins)
void MsgQueueOnOff(bool sw) HS_OVERRIDE;

static void SetMsgRecieveCallback(MsgRecieveCallback callback) { fMsgRecieveCallback = callback; }
// On starts deferring msg delivery until buffering is set to off again.
bool SetMsgBuffering(bool on) HS_OVERRIDE;

void BeginShutdown() HS_OVERRIDE;

static void SetMsgRecieveCallback(MsgRecieveCallback callback) {
fMsgRecieveCallback = callback;
}
};


class plNullDispatch : public plDispatch
{
public:

virtual void RegisterForExactType(uint16_t hClass, const plKey& receiver) {}
virtual void RegisterForType(uint16_t hClass, const plKey& receiver) {}

virtual void UnRegisterForExactType(uint16_t hClass, const plKey& receiver) {}
virtual void UnRegisterForType(uint16_t hClass, const plKey& receiver) {}
void RegisterForExactType(uint16_t hClass, const plKey& receiver) HS_OVERRIDE {}
void RegisterForType(uint16_t hClass, const plKey& receiver) HS_OVERRIDE {}

void UnRegisterForExactType(uint16_t hClass, const plKey& receiver) HS_OVERRIDE {}
void UnRegisterForType(uint16_t hClass, const plKey& receiver) HS_OVERRIDE {}

virtual bool MsgSend(plMessage* msg) { return true; }
virtual void MsgQueue(plMessage* msg) {}
virtual void MsgQueueProcess() {}
bool MsgSend(plMessage* msg, bool async=false) HS_OVERRIDE { return true; }
void MsgQueue(plMessage* msg) HS_OVERRIDE {}
void MsgQueueProcess() HS_OVERRIDE {}

virtual void BeginShutdown() {}
void BeginShutdown() HS_OVERRIDE {}

};

Expand Down
3 changes: 1 addition & 2 deletions Sources/Plasma/NucleusLib/pnDispatch/pnDispatchCreatable.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnFactory/plCreatable.h"

#include "plDispatch.h"

REGISTER_CREATABLE( plDispatch );
REGISTER_CREATABLE(plDispatch);

#endif // pnDispatchCreatable_inc
Loading