Multicaster.h
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:1k
- #ifndef MULTICASTER_H
- #define MULTICASTER_H
- #include <map>
- #include <vector>
- #include <string>
- class Value
- {
- };
- class MulticastObserver
- {
- public:
- virtual void accept (std::string address, Value value) = 0;
- };
- typedef std::vector<MulticastObserver *> Subscriptions;
- typedef std::map<std::string,Subscriptions> AddressSpace;
- class Multicaster
- {
- public:
- virtual ~Multicaster () {}
- virtual bool subscribe (MulticastObserver *observer, std::string address);
- virtual bool unsubscribe (MulticastObserver *observer, std::string address);
- virtual bool publish (MulticastObserver *observer, std::string address, Value value);
- virtual void unsubscribeFromAll (MulticastObserver *observer);
- private:
- AddressSpace m_addresses;
- void unsubscribe (Subscriptions& subscriptions, MulticastObserver *observerToRemove);
- };
- #endif