Torque3D Documentation / _generateds / scriptMsgListener.h

scriptMsgListener.h

Engine/source/util/messaging/scriptMsgListener.h

More...

Classes:

class

Script accessible version of Dispatcher::IMessageListener.

Detailed Description

 1
 2//-----------------------------------------------------------------------------
 3// Copyright (c) 2012 GarageGames, LLC
 4//
 5// Permission is hereby granted, free of charge, to any person obtaining a copy
 6// of this software and associated documentation files (the "Software"), to
 7// deal in the Software without restriction, including without limitation the
 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 9// sell copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21// IN THE SOFTWARE.
22//-----------------------------------------------------------------------------
23
24#include "console/simBase.h"
25
26#ifndef _SCRIPTMSGLISTENER_H_
27#define _SCRIPTMSGLISTENER_H_
28
29#ifndef _DISPATCHER_H_
30#include "util/messaging/dispatcher.h"
31#endif
32
33/// @addtogroup msgsys Message System
34// @{
35
36//-----------------------------------------------------------------------------
37/// @brief Script accessible version of Dispatcher::IMessageListener
38///
39/// The main use of ScriptMsgListener is to allow script to listen for
40/// messages. You can subclass ScriptMsgListener in script to receive
41/// the Dispatcher::IMessageListener callbacks.
42///
43/// Alternatively, you can derive from it in C++ instead of SimObject to
44/// get an object that implements Dispatcher::IMessageListener with script
45/// callbacks. If you need to derive from something other then SimObject,
46/// then you will need to implement the Dispatcher::IMessageListener
47/// interface yourself.
48//-----------------------------------------------------------------------------
49class ScriptMsgListener : public SimObject, public virtual Dispatcher::IMessageListener
50{
51   typedef SimObject Parent;
52   typedef Dispatcher::IMessageListener IMLParent;
53
54public:
55   ScriptMsgListener();
56
57   DECLARE_CONOBJECT(ScriptMsgListener);
58   
59   DECLARE_CALLBACK( void, onAdd, () );
60   DECLARE_CALLBACK( void, onRemove, () );
61
62   DECLARE_CALLBACK( bool, onMessageReceived, ( const char* queue, const char* event, const char* data ) );
63   DECLARE_CALLBACK( bool, onMessageObjectReceived, ( const char* queue, Message *msg ) );
64   
65   DECLARE_CALLBACK( void, onAddToQueue, ( const char* queue ) );
66   DECLARE_CALLBACK( void, onRemoveFromQueue, ( const char* queue ) );
67
68   ///////////////////////////////////////////////////////////////////////
69
70   virtual bool onAdd();
71   virtual void onRemove();
72
73   ///////////////////////////////////////////////////////////////////////
74
75   virtual bool onMessageReceived(StringTableEntry queue, const char* event, const char* data);
76   virtual bool onMessageObjectReceived(StringTableEntry queue, Message *msg);
77
78   virtual void onAddToQueue(StringTableEntry queue);
79   virtual void onRemoveFromQueue(StringTableEntry queue);
80};
81
82// @}
83
84#endif // _SCRIPTMSGLISTENER_H_
85