ctkEventBusImpl_p.h 969 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef CTKEVENTBUSIMPL_H
  2. #define CTKEVENTBUSIMPL_H
  3. #include <EventBus/ctkEventBus.h>
  4. #include <QList>
  5. #include <QHash>
  6. #include <QSet>
  7. class ctkEventHandlerWrapper;
  8. class ctkEventBusImpl : public QObject,
  9. public ctkEventBus
  10. {
  11. Q_OBJECT
  12. Q_INTERFACES(ctkEventBus)
  13. public:
  14. static ctkEventBusImpl* instance();
  15. void postEvent(const ctkEvent& event);
  16. void sendEvent(const ctkEvent& event);
  17. void publishSignal(const QObject* publisher, const char* signal);
  18. void subscribeSlot(const QObject* subscriber, const char* member, const Properties& properties);
  19. protected:
  20. typedef QList<ctkEventHandlerWrapper*> HandlerList;
  21. HandlerList globalWildcard;
  22. QHash<QString, HandlerList> topicName;
  23. void dispatchEvent(const ctkEvent& event, bool isAsync);
  24. void bucket(ctkEventHandlerWrapper* wrapper);
  25. QSet<ctkEventHandlerWrapper*> handlers(const QString& topic);
  26. private:
  27. ctkEventBusImpl();
  28. };
  29. #endif // CTKEVENTBUSIMPL_H