unilink  0.4.3
A simple C++ library for unified async communication
unilink.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2025 Jinwoo Sung
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <memory>
20 #include <variant>
21 
26 
27 // Public API Context and Interface headers
31 
32 // Wrapper implementations
37 
38 // High-level Builder API includes
45 
46 // Configuration Management API includes (optional)
47 #ifdef UNILINK_ENABLE_CONFIG
51 #endif
52 
53 // Error handling and logging system includes
56 
57 namespace unilink {
58 
59 // === Public API Namespaces ===
60 
61 // Builder API namespace
62 namespace builder {
63 class TcpServerBuilder;
64 class TcpClientBuilder;
65 class SerialBuilder;
66 class UdpBuilder;
67 class UnifiedBuilder;
68 } // namespace builder
69 
70 // Wrapper API namespace
71 namespace wrapper {
72 class TcpServer;
73 class TcpClient;
74 class Serial;
75 class Udp;
76 class ChannelInterface;
77 class ServerInterface;
78 class MessageContext;
79 class ConnectionContext;
80 class ErrorContext;
81 } // namespace wrapper
82 
83 // === Public Facade Aliases ===
84 
85 // Core communication classes
89 using Udp = wrapper::Udp;
90 
91 // Context classes for callbacks
95 
96 // === Public Builder API Convenience Functions ===
97 
103 inline builder::TcpServerBuilder tcp_server(uint16_t port) { return builder::TcpServerBuilder(port); }
104 
111 inline builder::TcpClientBuilder tcp_client(const std::string& host, uint16_t port) {
112  return builder::TcpClientBuilder(host, port);
113 }
114 
121 inline builder::SerialBuilder serial(const std::string& device, uint32_t baud_rate) {
122  return builder::SerialBuilder(device, baud_rate);
123 }
124 
130 inline builder::UdpBuilder udp(uint16_t local_port) {
132  b.set_local_port(local_port);
133  return b;
134 }
135 
136 } // namespace unilink