ctkEvent.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 CTKEVENT_H
  16. #define CTKEVENT_H
  17. #include "ctkPluginFrameworkExport.h"
  18. #include <QMap>
  19. #include <QVariant>
  20. #include <QStringList>
  21. #include <ctkLDAPSearchFilter.h>
  22. class ctkEventPrivate;
  23. /**
  24. * A CTK event.
  25. *
  26. * <code>ctkEvent</code> objects are delivered to Qt slots
  27. * which subscribe to the topic of the event.
  28. */
  29. class CTK_PLUGINFW_EXPORT ctkEvent {
  30. public:
  31. /**
  32. * Constructs an event.
  33. *
  34. * @param topic The topic of the event.
  35. * @param properties The event's properties (may be empty).
  36. * @throws std::invalid_argument If topic is not a valid topic name.
  37. */
  38. ctkEvent(const QString& topic, const ctkDictionary& properties = ctkDictionary());
  39. ctkEvent(const ctkEvent& event);
  40. ~ctkEvent();
  41. /**
  42. * Compares this <code>ctkEvent</code> object to another object.
  43. *
  44. * <p>
  45. * An event is considered to be <b>equal to</b> another event if the topic
  46. * is equal and the properties are equal.
  47. *
  48. * @param object The <code>ctkEvent</code> object to be compared.
  49. * @return <code>true</code> if <code>other</code> is equal to
  50. * this object; <code>false</code> otherwise.
  51. */
  52. bool operator==(const ctkEvent& other) const;
  53. /**
  54. * Retrieves a property.
  55. *
  56. * @param name the name of the property to retrieve
  57. * @return The value of the property, or an invalid QVariant if not found.
  58. */
  59. QVariant property(const QString& name) const;
  60. /**
  61. * Returns a list of this event's property names.
  62. *
  63. * @return A non-empty list with one element per property.
  64. */
  65. QStringList propertyNames() const;
  66. /**
  67. * Returns the topic of this event.
  68. *
  69. * @return The topic of this event.
  70. */
  71. const QString& topic() const;
  72. /**
  73. * Tests this event's properties against the given filter using a case
  74. * sensitive match.
  75. *
  76. * @param filter The filter to test.
  77. * @return true If this event's properties match the filter, false
  78. * otherwise.
  79. */
  80. bool matches(const ctkLDAPSearchFilter& filter) const;
  81. protected:
  82. ctkEventPrivate * const d;
  83. };
  84. #endif // CTKEVENT_H