ctkEvent.cpp 1.2 KB

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