ctkEventAdminService_p.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 CTKEVENTADMINSERVICE_P_H
  16. #define CTKEVENTADMINSERVICE_P_H
  17. #include <QObject>
  18. #include <service/event/ctkEventAdmin.h>
  19. #include "ctkEventAdminImpl_p.h"
  20. #include "handler/ctkEACleanBlackList_p.h"
  21. #include "util/ctkEALeastRecentlyUsedCacheMap_p.h"
  22. #include "handler/ctkEACacheTopicHandlerFilters_p.h"
  23. #include "handler/ctkEACacheFilters_p.h"
  24. #include "tasks/ctkEASyncDeliverTasks_p.h"
  25. #include "tasks/ctkEAAsyncDeliverTasks_p.h"
  26. #include "dispatch/ctkEASignalPublisher_p.h"
  27. class ctkEASlotHandler;
  28. class ctkEventAdminService : public QObject, public ctkEventAdmin
  29. {
  30. Q_OBJECT
  31. Q_INTERFACES(ctkEventAdmin)
  32. public:
  33. typedef ctkEACleanBlackList BlackList;
  34. typedef ctkEABlackList<BlackList> BlackListInterface;
  35. typedef ctkEALeastRecentlyUsedCacheMap<QString, QString> TopicCacheMap;
  36. typedef ctkEACacheTopicHandlerFilters<TopicCacheMap> TopicHandlerFilters;
  37. typedef ctkEATopicHandlerFilters<TopicHandlerFilters> TopicHandlerFiltersInterface;
  38. typedef ctkEALeastRecentlyUsedCacheMap<QString, ctkLDAPSearchFilter> LDAPCacheMap;
  39. typedef ctkEACacheFilters<LDAPCacheMap> Filters;
  40. typedef ctkEAFilters<Filters> FiltersInterface;
  41. typedef ctkEABlacklistingHandlerTasks<BlackList, TopicHandlerFilters, Filters> BlacklistingHandlerTasks;
  42. typedef ctkEAHandlerTasks<BlacklistingHandlerTasks> HandlerTasksInterface;
  43. typedef ctkEAHandlerTask<BlacklistingHandlerTasks> HandlerTask;
  44. typedef HandlerTask HandlerTaskInterface;
  45. typedef ctkEASyncDeliverTasks<HandlerTask> SyncDeliverTasks;
  46. typedef ctkEADeliverTask<SyncDeliverTasks, HandlerTask> SyncDeliverTasksInterface;
  47. typedef ctkEAAsyncDeliverTasks<SyncDeliverTasks, HandlerTask> AsyncDeliverTasks;
  48. typedef ctkEADeliverTask<AsyncDeliverTasks, HandlerTask> AsyncDeliverTasksInterface;
  49. private:
  50. ctkEventAdminImpl<BlacklistingHandlerTasks, SyncDeliverTasks, AsyncDeliverTasks> impl;
  51. ctkPluginContext* context;
  52. QHash<const QObject*, QList<ctkEASignalPublisher*> > signalPublisher;
  53. QHash<qlonglong, ctkEASlotHandler*> slotHandler;
  54. public:
  55. ctkEventAdminService(ctkPluginContext* context,
  56. HandlerTasksInterface* managers,
  57. ctkEADefaultThreadPool* syncPool,
  58. ctkEADefaultThreadPool* asyncPool,
  59. int timeout,
  60. const QStringList& ignoreTimeout);
  61. ~ctkEventAdminService();
  62. void postEvent(const ctkEvent& event);
  63. void sendEvent(const ctkEvent& event);
  64. void publishSignal(const QObject* publisher, const char* signal,
  65. const QString& topic,
  66. Qt::ConnectionType type = Qt::QueuedConnection);
  67. void unpublishSignal(const QObject* publisher, const char* signal = 0,
  68. const QString& topic = "");
  69. qlonglong subscribeSlot(const QObject* subscriber, const char* member,
  70. const ctkDictionary& properties, Qt::ConnectionType type = Qt::AutoConnection);
  71. void unsubscribeSlot(qlonglong subscriptionId);
  72. bool updateProperties(qlonglong subscriptionId, const ctkDictionary& properties);
  73. /**
  74. * This method can be used to stop the delivery of events. The managers variable is
  75. * replaced with a null object that throws an ctkIllegalStateException on a call
  76. * to <tt>createHandlerTasks()</tt>.
  77. */
  78. void stop();
  79. /**
  80. * Update the event admin with new configuration.
  81. */
  82. void update(HandlerTasksInterface* managers, int timeout,
  83. const QStringList& ignoreTimeout);
  84. };
  85. #endif // CTKEVENTADMINSERVICE_P_H