ctkEventBus.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef CTKEVENTBUS_H
  2. #define CTKEVENTBUS_H
  3. #include "ctkEvent.h"
  4. <<<<<<< Updated upstream
  5. class ctkEventBus {
  6. =======
  7. /**
  8. * The Event Bus service. Plugins wishing to publish events can either
  9. * obtain the Event Bus service and call one of the event delivery methods
  10. * or publish a Qt signal for a specific event topic.
  11. *
  12. */
  13. class CTK_PLUGINFW_EXPORT ctkEventBus {
  14. >>>>>>> Stashed changes
  15. public:
  16. virtual ~ctkEventBus() {}
  17. /**
  18. * Initiate asynchronous delivery of an event. This method returns to the
  19. * caller before delivery of the event is completed.
  20. *
  21. * @param event The event to send to all listeners which subscribe to the
  22. * topic of the event.
  23. *
  24. */
  25. virtual void postEvent(const ctkEvent& event) = 0;
  26. /**
  27. * Initiate synchronous delivery of an event. This method does not return to
  28. * the caller until delivery of the event is completed.
  29. *
  30. * @param event The event to send to all listeners which subscribe to the
  31. * topic of the event.
  32. *
  33. */
  34. virtual void sendEvent(const ctkEvent& event) = 0;
  35. <<<<<<< Updated upstream
  36. virtual void publishSignal(const QObject* publisher, const char* signal) = 0;
  37. =======
  38. /**
  39. * Publish (register) a Qt signal for event delivery. Emitting the signal
  40. * has the same effect as calling postEvent() if <code>type</code> is
  41. * Qt::QueuedConnection and as sendEvent() if <code>type</code> is
  42. * Qt::DirectConnection.
  43. *
  44. * @param publisher The owner of the signal.
  45. * @param signal The signal in normalized form.
  46. * @param signal_topic The topic string for the events this signal is emitting.
  47. * @param type Qt::QueuedConnection for asynchronous delivery and
  48. * Qt::DirectConnection for synchronous delivery.
  49. */
  50. virtual void publishSignal(const QObject* publisher, const char* signal,
  51. const QString& signal_topic, Qt::ConnectionType type = Qt::QueuedConnection) = 0;
  52. /**
  53. * Subsribe for (observe) events. The slot is called whenever an event is sent
  54. * which matches the supplied properties.
  55. *
  56. * Slots should be registered with a property EventConstants::EVENT_TOPIC.
  57. * The value being a QString or QStringList object that describes which
  58. * topics the slot is interested in. A wildcard (’*’ \u002A) may be used as
  59. * the last token of a topic name, for example com/action/*. This matches any
  60. * topic that shares the same first tokens. For example, com/action/* matches
  61. * com/action/listen. Slot which have not been specified with the EVENT_TOPIC
  62. * property must not receive events.
  63. * The value of each entry in the EVENT_TOPIC property must conform to the
  64. * following grammar:
  65. * \verbatim
  66. * topic-scope ::= ’*’ | ( topic ’/*’ ? )
  67. * \endverbatim
  68. *
  69. * Slots can also be registered with a property named EventConstants::EVENT_FILTER.
  70. * The value of this property must be a string containing a filter specification.
  71. * Any of the event's properties can be used in the filter expression.
  72. * Each slot is notified for any event which belongs to the topics the
  73. * slot has expressed an interest in. If the handler has defined a
  74. * EVENT_FILTER property then the event properties must also match the filter
  75. * expression. If the filter is an error, then the Event Bus service
  76. * should log a warning and further ignore the registered slot.
  77. *
  78. * @param subscriber The owner of the slot.
  79. * @param member The slot in normalized form.
  80. * @param properties A map containing topics and a filter expression.
  81. * @return Returns an id which can be used to update the properties.
  82. */
  83. virtual QString subscribeSlot(const QObject* subscriber, const char* member, const ctkProperties& properties) = 0;
  84. >>>>>>> Stashed changes
  85. /**
  86. * Updates the properties of a previously registered slot. This can be used
  87. * to change the topics the slot is interested in or to change the filter expression.
  88. * A previously registered property can be removed by providing an invalid QVariant.
  89. *
  90. * @param subscriptionId The slot id obtained by a call to subscribeSlot().
  91. * @param properties The properties which should be updated.
  92. */
  93. virtual void updateProperties(const QString& subsriptionId, const ctkProperties& properties) = 0;
  94. };
  95. Q_DECLARE_INTERFACE(ctkEventBus, "org.commontk.core.ctkEventBus")
  96. #endif // CTKEVENTBUS_H