ctkTopicRegistry.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * ctkTopicRegistry.h
  3. * ctkEventBus
  4. *
  5. * Created by Roberto Mucci on 26/01/11.
  6. * Copyright 2011 B3C. All rights reserved.
  7. *
  8. * See Licence at: http://tiny.cc/QXJ4D
  9. *
  10. */
  11. #ifndef CTKTOPICREGISTRY_H
  12. #define CTKTOPICREGISTRY_H
  13. // Includes list
  14. #include "ctkEventDefinitions.h"
  15. namespace ctkEventBus {
  16. /**
  17. Class name: ctkTopicRegistry
  18. This singletone provides the registration of topic and topic owner in a hash.
  19. */
  20. class org_commontk_eventbus_EXPORT ctkTopicRegistry {
  21. public:
  22. /// Return an instance of the event bus.
  23. static ctkTopicRegistry *instance();
  24. /// Destroy the singleton instance. To be called at the end of the application.
  25. void shutdown();
  26. /// Register a new topic.
  27. bool registerTopic(const QString topic, const QObject *owner);
  28. /// Unregister a topic.
  29. bool unregisterTopic(const QString topic);
  30. /// Return the owner of a topic.
  31. const QObject *owner(const QString topic) const;
  32. /// Check if a topic is present in the topic hash.
  33. bool isTopicRegistered(const QString topic) const;
  34. /// Dump of the topic hash.
  35. void dump();
  36. private:
  37. /// Object constructor.
  38. ctkTopicRegistry();
  39. QHash<QString, const QObject*> m_TopicHash; ///< Hash containing pairs (topic,owner).
  40. };
  41. } //nameSpace ctkEventBus
  42. #endif // MAFTOPICREGISTRY_H