ctkBusEvent.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 CTKBUSEVENT_H
  16. #define CTKBUSEVENT_H
  17. #include "org_commontk_eventbus_Export.h"
  18. #include "ctkPluginFrameworkExport.h"
  19. #include <service/event/ctkEvent.h>
  20. #include <QMap>
  21. #include <QVariant>
  22. #include <QStringList>
  23. class ctkBusEventData;
  24. /**
  25. * A CTK event.
  26. *
  27. * <code>ctkEvent</code> objects are delivered to <code>ctkEventHandler</code>
  28. * or Qt slots which subscribe to the topic of the event.
  29. */
  30. class org_commontk_eventbus_EXPORT ctkBusEvent : public ctkEvent
  31. {
  32. QSharedDataPointer<ctkBusEventData> d;
  33. public:
  34. /**
  35. * Default constructor for use with the Qt meta object system.
  36. */
  37. ctkBusEvent();
  38. ~ctkBusEvent();
  39. /**
  40. * Constructs an event.
  41. *
  42. * @param topic The topic of the event.
  43. * @param properties The event's properties (may be empty).
  44. * @throws ctkInvalidArgumentException If topic is not a valid topic name.
  45. */
  46. ctkBusEvent(const QString& topic, const ctkDictionary& properties = ctkDictionary());
  47. ctkBusEvent(const ctkBusEvent& event);
  48. ctkBusEvent(QString topic, int event_type, int signature_type, QObject *objectPointer, QString signature);
  49. ctkBusEvent& operator=(const ctkBusEvent& event);
  50. /**
  51. * accessor for eventtype
  52. *
  53. * @param et The eventtype can be local(ctkEventTypeLocal) or remote(ctkEventTypeRemote)
  54. */
  55. void setEventType(int et);
  56. int eventType() const;
  57. bool isEventLocal() const;
  58. /**
  59. * accessor for topic
  60. *
  61. * @param topic Represents the topic of the message
  62. */
  63. void setEventTopic(QString topic);
  64. QString eventTopic() const;
  65. /**
  66. * quick accessor for all the items
  67. *
  68. * @param key Represents the key associated to the value
  69. */
  70. QVariant &operator[](QString key);
  71. };
  72. #endif // CTKBUSEVENT_H