2
0

BsMessageHandlerFwd.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #pragma once
  2. namespace BansheeEngine
  3. {
  4. /**
  5. * @brief Identifier for message used with the global messaging system.
  6. *
  7. * @note Primary purpose of this class is to avoid expensive string compare (i.e. button names),
  8. * and instead use a unique message identifier for compare. Generally you want to create
  9. * one of these using the message name, and then store it for later use.
  10. *
  11. * This class is not thread safe and should only be used on the sim thread.
  12. */
  13. class BS_UTILITY_EXPORT MessageId
  14. {
  15. public:
  16. MessageId();
  17. MessageId(const String& name);
  18. bool operator== (const MessageId& rhs) const
  19. {
  20. return (mMsgIdentifier == rhs.mMsgIdentifier);
  21. }
  22. private:
  23. friend class MessageHandler;
  24. static Map<String, UINT32> UniqueMessageIds;
  25. static UINT32 NextMessageId;
  26. UINT32 mMsgIdentifier;
  27. };
  28. /**
  29. * @brief Handle to a subscription for a specific message
  30. * in the global messaging system.
  31. */
  32. class BS_UTILITY_EXPORT HMessage
  33. {
  34. public:
  35. HMessage();
  36. /**
  37. * @brief Disconnects the message listener so it will no longer
  38. * receive events from the messaging system.
  39. */
  40. void disconnect();
  41. private:
  42. friend class MessageHandler;
  43. HMessage(UINT32 id);
  44. UINT32 mId;
  45. };
  46. /**
  47. * @brief Sends a message using the global messaging system.
  48. *
  49. * @note Sim thread only.
  50. */
  51. void BS_UTILITY_EXPORT sendMessage(MessageId message);
  52. class MessageHandler;
  53. }