| | |
| | | #include <mutex> |
| | | #include <set> |
| | | #include <unordered_map> |
| | | using namespace bhome_shm; |
| | | |
| | | // publish/subcribe manager. |
| | | class PubSubCenter |
| | |
| | | class SocketBus : public ShmSocket |
| | | { |
| | | public: |
| | | SocketBus(SharedMemory &shm) : |
| | | ShmSocket(shm, &kBHBusQueueId, 1000) {} |
| | | SocketBus(ShmSocket::Shm &shm) : |
| | | ShmSocket(shm, &kBHTopicBus, 1000) {} |
| | | using ShmSocket::shm; |
| | | }; |
| | | SocketBus socket_; |
| | | ShmSocket::Shm &shm() { return socket_.shm(); } |
| | | std::mutex mutex_; |
| | | typedef std::set<MQId> Clients; |
| | | std::unordered_map<std::string, Clients> records_; |
| | | ShmSocket::Shm &shm() { return socket_.shm(); } |
| | | |
| | | public: |
| | | PubSubCenter(SharedMemory &shm); |
| | | PubSubCenter(ShmSocket::Shm &shm) : |
| | | socket_(shm) {} |
| | | PubSubCenter() : |
| | | PubSubCenter(BHomeShm()) {} |
| | | ~PubSubCenter() { Stop(); } |