/* * Copyright (c) 2023 Fancy Code. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef TCP_MODULE_IMPL_H #define TCP_MODULE_IMPL_H #include "StatusCode.h" #include "TcpModule.h" #include #define TCP_MODULE_INIT_NAME "UART" typedef struct tcp_module_header { const char *mCheckName; } TcpModuleHeader; class TcpModuleImpl { public: TcpModuleImpl(const TcpPram &uatrInfo); virtual ~TcpModuleImpl() = default; private: const StatusCode SetConfig(void); private: const TcpPram mUatrInfo; int mFd; }; // TODO: There may be a CPU byte alignment bug. typedef struct tcp_server TcpServer; typedef struct tcp_server { TcpModuleHeader mHeader; std::shared_ptr mTcpImpl; } TcpServer; void *NewTcpModuleImpl(const TcpPram &tcpParam); void *NewTcpServer(const TcpPram &tcpParam); static inline TcpServer *TcpModuleImplConvert(void *object) { return ((TcpServer *)(((char *)object) - sizeof(TcpModuleHeader))); } const char *GetTcpModuleName(void); #endif