Branch data Line data Source code
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 : : #include <memory>
19 : : #include <variant>
20 : :
21 : : #include "wirestead/base/error_codes.hpp"
22 : : #include "wirestead/base/platform.hpp"
23 : : #include "wirestead/base/visibility.hpp"
24 : : #include "wirestead/interface/connection_channel.hpp"
25 : : #include "wirestead/interface/result_channel.hpp"
26 : :
27 : : // Public API Context and Interface headers
28 : : #include "wirestead/wrapper/context.hpp"
29 : : #include "wirestead/wrapper/fanout_result.hpp"
30 : : #include "wirestead/wrapper/ichannel.hpp"
31 : : #include "wirestead/wrapper/iserver.hpp"
32 : : #include "wirestead/wrapper/runtime_stats.hpp"
33 : : #include "wirestead/wrapper/send_result.hpp"
34 : :
35 : : // Wrapper implementations
36 : : #include "wirestead/wrapper/serial/serial.hpp"
37 : : #include "wirestead/wrapper/tcp_client/tcp_client.hpp"
38 : : #include "wirestead/wrapper/tcp_server/tcp_server.hpp"
39 : : #include "wirestead/wrapper/udp/udp.hpp"
40 : : #include "wirestead/wrapper/udp/udp_server.hpp"
41 : : #include "wirestead/wrapper/uds_client/uds_client.hpp"
42 : : #include "wirestead/wrapper/uds_server/uds_server.hpp"
43 : :
44 : : // High-level Builder API includes
45 : : #include "wirestead/builder/ibuilder.hpp"
46 : : #include "wirestead/builder/serial_builder.hpp"
47 : : #include "wirestead/builder/tcp_client_builder.hpp"
48 : : #include "wirestead/builder/tcp_server_builder.hpp"
49 : : #include "wirestead/builder/udp_builder.hpp"
50 : : #include "wirestead/builder/uds_builder.hpp"
51 : : #include "wirestead/builder/unified_builder.hpp"
52 : :
53 : : // Configuration Management API includes (optional)
54 : : #ifdef WIRESTEAD_ENABLE_CONFIG
55 : : #include "wirestead/config/config_factory.hpp"
56 : : #include "wirestead/config/config_manager.hpp"
57 : : #include "wirestead/config/iconfig_manager.hpp"
58 : : #endif
59 : :
60 : : // Io thread policy hook
61 : : #include "wirestead/concurrency/io_thread_hook.hpp"
62 : :
63 : : // Error handling and logging system includes
64 : : #include "wirestead/diagnostics/error_handler.hpp"
65 : : #include "wirestead/diagnostics/logger.hpp"
66 : :
67 : : namespace wirestead {
68 : :
69 : : // === Public Facade Aliases ===
70 : :
71 : : // Core communication classes
72 : : using TcpClient = wrapper::TcpClient;
73 : : using TcpServer = wrapper::TcpServer;
74 : : using Serial = wrapper::Serial;
75 : : using UdpClient = wrapper::UdpClient;
76 : : using UdpServer = wrapper::UdpServer;
77 : : using UdsClient = wrapper::UdsClient;
78 : : using UdsServer = wrapper::UdsServer;
79 : :
80 : : // Context classes for callbacks
81 : : using MessageContext = wrapper::MessageContext;
82 : : using ConnectionContext = wrapper::ConnectionContext;
83 : : using ErrorContext = wrapper::ErrorContext;
84 : : using RuntimeStats = wrapper::RuntimeStats;
85 : : using SendResult = wrapper::SendResult;
86 : : using FanoutResult = wrapper::FanoutResult;
87 : : using SendRejection = wrapper::SendRejection;
88 : :
89 : : // === Public Builder API Convenience Functions ===
90 : :
91 : : /**
92 : : * @brief Create a TCP server builder
93 : : * @param port The port number for the server
94 : : * @return TcpServerBuilderDefault A configured builder for TcpServer
95 : : */
96 : 114 : inline builder::TcpServerBuilderDefault tcp_server(uint16_t port) { return builder::TcpServerBuilderDefault(port); }
97 : :
98 : : /**
99 : : * @brief Create a TCP client builder
100 : : * @param host The host address to connect to
101 : : * @param port The port number to connect to
102 : : * @return TcpClientBuilderDefault A configured builder for TcpClient
103 : : */
104 : 96 : inline builder::TcpClientBuilderDefault tcp_client(const std::string& host, uint16_t port) {
105 : 96 : return builder::TcpClientBuilderDefault(host, port);
106 : : }
107 : :
108 : : /**
109 : : * @brief Create a UDS server builder
110 : : * @param socket_path The path to the Unix Domain Socket file
111 : : * @return UdsServerBuilderDefault A configured builder for UdsServer
112 : : */
113 : 13 : inline builder::UdsServerBuilderDefault uds_server(const std::string& socket_path) {
114 : 13 : return builder::UdsServerBuilderDefault(socket_path);
115 : : }
116 : :
117 : : /**
118 : : * @brief Create a UDS client builder
119 : : * @param socket_path The path to the Unix Domain Socket file
120 : : * @return UdsClientBuilderDefault A configured builder for UdsClient
121 : : */
122 : 18 : inline builder::UdsClientBuilderDefault uds_client(const std::string& socket_path) {
123 : 18 : return builder::UdsClientBuilderDefault(socket_path);
124 : : }
125 : :
126 : : /**
127 : : * @brief Create a Serial port builder
128 : : * @param device The serial device path (e.g., "/dev/ttyUSB0")
129 : : * @param baud_rate The baud rate for serial communication
130 : : * @return SerialBuilderDefault A configured builder for Serial
131 : : */
132 : 28 : inline builder::SerialBuilderDefault serial(const std::string& device, uint32_t baud_rate) {
133 : 28 : return builder::SerialBuilderDefault(device, baud_rate);
134 : : }
135 : :
136 : : /**
137 : : * @brief Create a UDP client builder
138 : : * @param local_port The local port to bind
139 : : * @return UdpClientBuilderDefault A configured builder for UDP Client
140 : : */
141 : 3 : inline builder::UdpClientBuilderDefault udp_client(uint16_t local_port) {
142 : 3 : return builder::UdpClientBuilderDefault(local_port);
143 : : }
144 : :
145 : : /**
146 : : * @brief Create a UDP server builder (Virtual sessions)
147 : : * @param local_port The local port to bind
148 : : * @return UdpServerBuilderDefault A configured builder for UDP Server
149 : : */
150 : : inline builder::UdpServerBuilderDefault udp_server(uint16_t local_port) {
151 : : return builder::UdpServerBuilderDefault(local_port);
152 : : }
153 : :
154 : : } // namespace wirestead
|