ctkEvent.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #include "ctkEvent.h"
  2. class EventPrivate {
  3. public:
  4. EventPrivate(const QString& topic, const LDAPSearchFilter::Dictionary& properties)
  5. : ref(1), topic(topic), properties(properties)
  6. {
  7. }
  8. QAtomicInt ref;
  9. const QString topic;
  10. const LDAPSearchFilter::Dictionary properties;
  11. };
  12. Event::Event(const QString& topic, const LDAPSearchFilter::Dictionary& properties)
  13. : d(new EventPrivate(topic, properties))
  14. {
  15. }
  16. /*
  17. * This is fast thanks to implicit sharing
  18. */
  19. Event::Event(const Event &event)
  20. : d(event.d)
  21. {
  22. d->ref.ref();
  23. }
  24. Event::~Event()
  25. {
  26. if (!d->ref.deref())
  27. delete d;
  28. }
  29. bool Event::operator==(const Event& other) const
  30. {
  31. if (d == other.d)
  32. return true;
  33. if (d->topic == other.d->topic &&
  34. d->properties == other.d->properties)
  35. return true;
  36. return false;
  37. }
  38. const QVariant& Event::property(const QString& name) const
  39. {
  40. d->properties[name];
  41. }
  42. QStringList Event::propertyNames() const
  43. {
  44. d->properties.keys();
  45. }
  46. const QString& Event::topic() const
  47. {
  48. d->topic;
  49. }
  50. bool Event::matches(const LDAPSearchFilter& filter) const
  51. {
  52. // TODO
  53. return true;
  54. }