diff --git a/utils/TcpModule/src/TcpServerHandle.cpp b/utils/TcpModule/src/TcpServerHandle.cpp index 3928fbae..e5cc292d 100644 --- a/utils/TcpModule/src/TcpServerHandle.cpp +++ b/utils/TcpModule/src/TcpServerHandle.cpp @@ -16,6 +16,12 @@ #include "ILog.h" #include "ITcpServer.h" #include + +/** + * @brief Get the singleton instance of TcpServerHandle + * @param impl Optional implementation pointer to replace the current instance + * @return The singleton instance of TcpServerHandle + */ std::shared_ptr &TcpServerHandle::GetInstance(std::shared_ptr *impl) { static auto instance = std::make_shared(); @@ -30,11 +36,24 @@ std::shared_ptr &TcpServerHandle::GetInstance(std::shared_ptr &server) { LogInfo("AddServer fd = %d\n", fd); mFd[fd] = server; } + +/** + * @brief Get a server by file descriptor + * @param fd File descriptor of the server + * @param server Reference to a shared pointer to store the ITcpServer instance + * @return True if the server is found, false otherwise + */ bool TcpServerHandle::GetServer(const int &fd, std::shared_ptr &server) { auto it = mFd.find(fd); diff --git a/utils/TcpModule/src/TcpServerHandle.h b/utils/TcpModule/src/TcpServerHandle.h index 646b2680..e7a6acf3 100644 --- a/utils/TcpModule/src/TcpServerHandle.h +++ b/utils/TcpModule/src/TcpServerHandle.h @@ -20,10 +20,32 @@ class TcpServerHandle { public: + /** + * @brief Default constructor + */ TcpServerHandle() = default; + /** + * @brief Default destructor + */ ~TcpServerHandle() = default; + /** + * @brief Get the singleton instance of TcpServerHandle + * @param impl Optional implementation pointer to replace the current instance + * @return The singleton instance of TcpServerHandle + */ static std::shared_ptr &GetInstance(std::shared_ptr *impl = nullptr); + /** + * @brief Add a server + * @param fd File descriptor of the server + * @param server Shared pointer to the ITcpServer instance + */ void AddServer(const int &fd, const std::shared_ptr &server); + /** + * @brief Get a server by file descriptor + * @param fd File descriptor of the server + * @param server Reference to a shared pointer to store the ITcpServer instance + * @return True if the server is found, false otherwise + */ bool GetServer(const int &fd, std::shared_ptr &server); private: