The HNetMessageRegistrar class maps messages from HNetClients or .snap files to MVO calls. More...
#include <HNetMessageRegistrar.h>
Public Member Functions | |
HNetMessageRegistrar (HBaseView *new_hbaseview, HNetClient *new_hnetclient=0) | |
bool | ReadSnapFile (const char *file_name) |
virtual void | SetHandlers () |
virtual HNetMessageHandler * | SetMessageHandler (HNetMessageHandler *handler, const char *message_type) |
virtual void | UnSetHandlers () |
virtual | ~HNetMessageRegistrar () |
Protected Member Functions | |
virtual void | ProcessMessage (const char *message, unsigned long message_length) |
Protected Attributes | |
HBaseView * | hbaseview |
This is the HBaseView for this registrar. | |
HNetClient * | hnetclient |
This is the HNetClient for this registrar. |
The HNetMessageRegistrar class maps messages from HNetClients or .snap files to MVO calls.
Subclassed HNetMessageHandler objects are registered for specific messages.
HNetMessageRegistrar::HNetMessageRegistrar | ( | HBaseView * | new_hbaseview, |
HNetClient * | new_hnetclient = 0 |
||
) | [inline] |
Constructs an HNetMessageRegistrar object.
new_hbaseview | This is a pointer to a HBaseView object this registrar instance will deliever messages to. |
new_hnetclient | Pass a pointer to an HNetClient will you want messages to come from that object or pass null for messages to be generated from .snap files. |
References hbaseview, and hnetclient.
virtual HNetMessageRegistrar::~HNetMessageRegistrar | ( | ) | [inline, virtual] |
The HNetMessageRegistrar destuctor cleans up all HMessageHandler class instance that have been added to it.
References UnSetHandlers().
virtual void HNetMessageRegistrar::ProcessMessage | ( | const char * | message, |
unsigned long | message_length | ||
) | [inline, protected, virtual] |
This is used by the snap file loader to send a single message.
message | A pointer to the message data. |
message_length | The lenght of the message data. |
References hnetclient.
Referenced by ReadSnapFile().
bool HNetMessageRegistrar::ReadSnapFile | ( | const char * | file_name | ) | [inline] |
A snap file created by a hnet_server may be loaded and "played back" using this method. It can only be used if the HMessageRegistrar was created without a HNetClient.
file_name | The name of the snap file to load. |
References hnetclient, and ProcessMessage().
virtual void HNetMessageRegistrar::SetHandlers | ( | ) | [inline, virtual] |
This method calls SetMessageHandler() for all default MVO messages. HNetMessageRegistrar may be subclassed to set custom message handlers. Custom handlers may also be set by calling SetMessageHandler() for the custom message handlers directly.
This function must be called by the user to set the default handlers. If it is not called, no default handlers will be set.
References hbaseview, and SetMessageHandler().
virtual HNetMessageHandler* HNetMessageRegistrar::SetMessageHandler | ( | HNetMessageHandler * | handler, |
const char * | message_type | ||
) | [inline, virtual] |
This method sets a handler for a specific message. The old handler if one existed is returned to caller.
handler | A pointer to a subclassed HNetMessageHandler for the specifed message. A value of 0 will unset the handler. |
message_type | A character pointer denoting the type of message to be handled. If message_type is 0, then the object is set as the default message handler and any message which doesn't have a specific handler is dispatched to the default handler. |
For example:
SetMessageHandler(0,"H_INSERT_NURBS");
This example removes the handler for message H_INSERT_NURBS.
SetMessageHandler( new HMarkupMessageHandler(hbaseview), "H_INSERT_MARKUP_LAYER_HSF_DATA");
This example sets HMarkupMessageHandler for message H_INSERT_MARKUP_LAYER_HSF_DATA.
SetMessageHandler( new MyDefaultHandler(hbaseview), 0);
This example sets MyDefaultHandler as the handler for all messages without other handlers.
References hnetclient.
Referenced by SetHandlers().
virtual void HNetMessageRegistrar::UnSetHandlers | ( | ) | [inline, virtual] |
This method clears all message handlers that have been set. It is called when the registrar is deleted but may be called at any time to remove handlers.
References hnetclient.
Referenced by ~HNetMessageRegistrar().