| | |
| | | |
| | | #include "socket.h" |
| | | #include <functional> |
| | | #include <map> |
| | | #include <memory> |
| | | |
| | | class BHCenter |
| | | { |
| | |
| | | |
| | | public: |
| | | typedef std::function<bool(ShmSocket &socket, bhome_msg::MsgI &imsg, bhome::msg::BHMsg &msg)> MsgHandler; |
| | | static bool Install(const std::string &name, MsgHandler handler, const std::string &mqid, const int mq_len); |
| | | |
| | | BHCenter(Socket::Shm &shm); |
| | | BHCenter(); |
| | | ~BHCenter() { Stop(); } |
| | | bool Start(); |
| | | bool Stop() { return socket_.Stop(); } |
| | | bool Stop(); |
| | | |
| | | private: |
| | | ShmSocket socket_; |
| | | struct CenterInfo { |
| | | std::string name_; |
| | | MsgHandler handler_; |
| | | std::string mqid_; |
| | | int mq_len_ = 0; |
| | | }; |
| | | typedef std::map<std::string, CenterInfo> CenterRecords; |
| | | static CenterRecords &Centers(); |
| | | |
| | | std::map<std::string, std::shared_ptr<ShmSocket>> sockets_; |
| | | }; |
| | | |
| | | #endif // end of include guard: CENTER_TM9OUQTG |