ctkEvent.cpp 1.2 KB

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