messageForwarder.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. /*
  23. ** Alive and Ticking
  24. ** (c) Copyright 2006 Burnt Wasp
  25. ** All Rights Reserved.
  26. **
  27. ** Filename: messageForwarder.h
  28. ** Author: Tom Bampton
  29. ** Created: 26/8/2006
  30. ** Purpose:
  31. ** Message Forwarder
  32. **
  33. */
  34. #include "sim/simBase.h"
  35. #include "messaging/dispatcher.h"
  36. #include "messaging/scriptMsgListener.h"
  37. #ifndef _MESSAGEFORWARDER_H_
  38. #define _MESSAGEFORWARDER_H_
  39. /// @addtogroup msgsys Message System
  40. // @{
  41. //////////////////////////////////////////////////////////////////////////
  42. /// @brief Forward messages from one queue to another
  43. ///
  44. /// MessageForwarder is a script class that can be used to forward messages
  45. /// from one queue to another.
  46. ///
  47. /// <h2>Example</h2>
  48. ///
  49. /// @code
  50. /// %fwd = new MessageForwarder()
  51. /// {
  52. /// toQueue = "QueueToSendTo";
  53. /// };
  54. ///
  55. /// registerMessageListener("FromQueue", %fwd);
  56. /// @endcode
  57. ///
  58. /// Where "QueueToSendTo" is the queue you want to forward to, and
  59. /// "FromQueue" is the queue you want to forward from.
  60. ///
  61. //////////////////////////////////////////////////////////////////////////
  62. class MessageForwarder : public ScriptMsgListener
  63. {
  64. typedef ScriptMsgListener Parent;
  65. protected:
  66. StringTableEntry mToQueue;
  67. public:
  68. MessageForwarder();
  69. virtual ~MessageForwarder();
  70. DECLARE_CONOBJECT(MessageForwarder);
  71. static void initPersistFields();
  72. virtual bool onMessageReceived(StringTableEntry queue, const char *event, const char *data);
  73. virtual bool onMessageObjectReceived(StringTableEntry queue, Message *msg);
  74. };
  75. // @}
  76. #endif // _MESSAGEFORWARDER_H_