HDLC-Daemon
SerialPortHandlerCollection.h
Go to the documentation of this file.
1 
22 #ifndef SERIAL_PORT_HANDLER_COLLECTION_H
23 #define SERIAL_PORT_HANDLER_COLLECTION_H
24 
25 #include <memory>
26 #include <string>
27 #include <map>
28 #include <boost/asio.hpp>
29 class HdlcdServerHandler;
30 class SerialPortHandler;
31 
32 class SerialPortHandlerCollection: public std::enable_shared_from_this<SerialPortHandlerCollection> {
33 public:
34  // CTOR and resetter
35  SerialPortHandlerCollection(boost::asio::io_service& a_IOService);
36  void Shutdown();
37 
38  std::shared_ptr<std::shared_ptr<SerialPortHandler>> GetSerialPortHandler(const std::string &a_SerialPortName, std::shared_ptr<HdlcdServerHandler> a_HdlcdServerHandler);
39 
40  // To be called by a SerialPortHandler
41  void DeregisterSerialPortHandler(std::shared_ptr<SerialPortHandler> a_SerialPortHandler);
42 
43 private:
44  // Members
45  boost::asio::io_service& m_IOService;
46  std::map<std::string, std::weak_ptr<std::shared_ptr<SerialPortHandler>>> m_SerialPortHandlerMap;
47 };
48 
49 #endif // SERIAL_PORT_HANDLER_COLLECTION_H
void DeregisterSerialPortHandler(std::shared_ptr< SerialPortHandler > a_SerialPortHandler)
SerialPortHandlerCollection(boost::asio::io_service &a_IOService)
std::shared_ptr< std::shared_ptr< SerialPortHandler > > GetSerialPortHandler(const std::string &a_SerialPortName, std::shared_ptr< HdlcdServerHandler > a_HdlcdServerHandler)