ctkEventBusImpl_p.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) German Cancer Research Center,
  4. Division of Medical and Biological Informatics
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #ifndef CTKEVENTBUSIMPL_H
  16. #define CTKEVENTBUSIMPL_H
  17. #include "ctkEventAdminBus.h"
  18. #include "ctkEventBusManager.h"
  19. #include <QList>
  20. #include <QHash>
  21. #include <QSet>
  22. //class forward
  23. class ctkEventHandlerWrapper;
  24. class ctkEventBusImpl : public QObject,
  25. public ctkEventAdminBus
  26. {
  27. Q_OBJECT
  28. Q_INTERFACES(ctkEventAdminBus)
  29. public:
  30. ctkEventBusImpl();
  31. void postEvent(const ctkEvent& event);
  32. void sendEvent(const ctkEvent& event);
  33. void publishSignal(const QObject* publisher, const char* signal, const QString& topic, Qt::ConnectionType type = Qt::QueuedConnection);
  34. void unpublishSignal(const QObject *publisher, const char *signal = 0, const QString &topic = "");
  35. //void publishSignal(const QObject* publisher, const char* signal, Qt::ConnectionType type = Qt::QueuedConnection);
  36. qlonglong subscribeSlot(const QObject* subscriber, const char* member, const ctkDictionary& properties, Qt::ConnectionType type = Qt::AutoConnection);
  37. virtual void unsubscribeSlot(qlonglong subscriptionId);
  38. virtual bool updateProperties(qlonglong subsriptionId, const ctkDictionary& properties);
  39. /// Create the server for remote communication according to the given protocol and listen port.
  40. virtual bool createServer(const QString &communication_protocol, unsigned int listen_port);
  41. /// Allow to start server listening.
  42. virtual void startListen();
  43. /// Create the client for remote communication according to the given protocol, server host and port.
  44. virtual bool createClient(const QString &communication_protocol, const QString &server_host, unsigned int port);
  45. protected:
  46. void dispatchEvent(const ctkEvent& event, bool isAsync);
  47. private:
  48. ctkEventBus::ctkEventBusManager *m_EventBusManager;
  49. };
  50. #endif // CTKEVENTBUSIMPL_H