Satellite-Gateway
ConfigServer.h
Go to the documentation of this file.
1 
24 #ifndef CONFIG_SERVER_H
25 #define CONFIG_SERVER_H
26 
27 #include <memory>
28 #include <boost/asio.hpp>
29 #include "ConfigFrame.h"
30 #include "FrameEndpoint.h"
32 #include "HdlcdClientErrorCodes.h"
35 
36 class ConfigServer {
37 public:
38  // CTOR, initializer, and resetter
39  ConfigServer(boost::asio::io_service& a_IOService, boost::asio::ip::tcp::tcp::socket& a_TcpSocket);
40  void SetOnClosedCallback(std::function<void()> a_OnClosedCallback) {
41  m_OnClosedCallback = a_OnClosedCallback;
42  }
43 
44  void Start(std::shared_ptr<GatewayClientHandlerCollection> a_GatewayClientHandlerCollection,
45  std::shared_ptr<HdlcdClientHandlerCollection> a_HdlcdClientHandlerCollection);
46  void Close();
47 
48  // Methods to be called by a gateway client entity
49  void GatewayClientCreated (uint16_t a_ReferenceNbr);
50  void GatewayClientDestroyed (uint16_t a_ReferenceNbr);
51  void GatewayClientConnected (uint16_t a_ReferenceNbr);
52  void GatewayClientDisconnected(uint16_t a_ReferenceNbr);
53  void GatewayClientError (uint16_t a_ReferenceNbr, E_GATEWAY_CLIENT_ERROR a_ErrorCode);
54 
55  // Methods to be called by a HDLCd client entity
56  void HdlcdClientCreated (uint16_t a_SerialPortNbr);
57  void HdlcdClientDestroyed (uint16_t a_SerialPortNbr);
58  void HdlcdClientConnected (uint16_t a_SerialPortNbr);
59  void HdlcdClientDisconnected(uint16_t a_SerialPortNbr);
60  void HdlcdClientNewStatus (uint16_t a_SerialPortNbr, bool a_bIsResumed, bool a_bIsAlive);
61  void HdlcdClientError (uint16_t a_SerialPortNbr, E_HDLCD_CLIENT_ERROR a_ErrorCode);
62 
63 private:
64  // Internal helpers
65  bool OnFrame(std::shared_ptr<Frame> a_Frame);
66  void OnClosed();
67 
68  // Members
69  boost::asio::io_service& m_IOService;
70  std::shared_ptr<GatewayClientHandlerCollection> m_GatewayClientHandlerCollection;
71  std::shared_ptr<HdlcdClientHandlerCollection> m_HdlcdClientHandlerCollection;
72 
73  // The communication end point
74  std::shared_ptr<FrameEndpoint> m_FrameEndpoint;
75  std::function<void()> m_OnClosedCallback;
76 };
77 
78 #endif // CONFIG_SERVER_H
This file contains the header declaration of class FrameEndpoint.
void HdlcdClientNewStatus(uint16_t a_SerialPortNbr, bool a_bIsResumed, bool a_bIsAlive)
E_GATEWAY_CLIENT_ERROR
void Start(std::shared_ptr< GatewayClientHandlerCollection > a_GatewayClientHandlerCollection, std::shared_ptr< HdlcdClientHandlerCollection > a_HdlcdClientHandlerCollection)
void HdlcdClientConnected(uint16_t a_SerialPortNbr)
void HdlcdClientCreated(uint16_t a_SerialPortNbr)
void HdlcdClientDisconnected(uint16_t a_SerialPortNbr)
E_HDLCD_CLIENT_ERROR
void GatewayClientCreated(uint16_t a_ReferenceNbr)
void GatewayClientConnected(uint16_t a_ReferenceNbr)
void GatewayClientDestroyed(uint16_t a_ReferenceNbr)
void HdlcdClientDestroyed(uint16_t a_SerialPortNbr)
void GatewayClientDisconnected(uint16_t a_ReferenceNbr)
void GatewayClientError(uint16_t a_ReferenceNbr, E_GATEWAY_CLIENT_ERROR a_ErrorCode)
void HdlcdClientError(uint16_t a_SerialPortNbr, E_HDLCD_CLIENT_ERROR a_ErrorCode)
ConfigServer(boost::asio::io_service &a_IOService, boost::asio::ip::tcp::tcp::socket &a_TcpSocket)
void SetOnClosedCallback(std::function< void()> a_OnClosedCallback)
Definition: ConfigServer.h:40