ctkEventBusImpl_p.h 1002 B

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