Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
895 B

  1. #ifndef MULTICASTER_H
  2. #define MULTICASTER_H
  3. #include <map>
  4. #include <vector>
  5. #include <string>
  6. class Value
  7. {
  8. };
  9. class MulticastObserver
  10. {
  11. public:
  12. virtual void accept (std::string address, Value value) = 0;
  13. };
  14. typedef std::vector<MulticastObserver *> Subscriptions;
  15. typedef std::map<std::string,Subscriptions> AddressSpace;
  16. class Multicaster
  17. {
  18. public:
  19. virtual ~Multicaster () {}
  20. virtual bool subscribe (MulticastObserver *observer, std::string address);
  21. virtual bool unsubscribe (MulticastObserver *observer, std::string address);
  22. virtual bool publish (MulticastObserver *observer, std::string address, Value value);
  23. virtual void unsubscribeFromAll (MulticastObserver *observer);
  24. private:
  25. AddressSpace m_addresses;
  26. void unsubscribe (Subscriptions& subscriptions, MulticastObserver *observerToRemove);
  27. };
  28. #endif