libe3 0.6.1
C++ library for E3AP RAN vendor integration
Loading...
Searching...
No Matches
connector_factory.cpp
Go to the documentation of this file.
1/**
2 * @file connector_factory.cpp
3 * @brief Factory for creating connector instances
4 *
5 * SPDX-FileCopyrightText: Copyright (c) 2026 Northeastern University
6 * SPDX-License-Identifier: Apache-2.0
7 */
8
10#if LIBE3_HAS_ZMQ
11#include "zmq_connector.hpp"
12#endif
13#include "posix_connector.hpp"
14#include "libe3/logger.hpp"
15
16namespace libe3 {
17
18std::unique_ptr<E3Connector> create_connector(
19 E3LinkLayer link_layer,
20 E3TransportLayer transport_layer,
21 const std::string& setup_endpoint,
22 const std::string& inbound_endpoint,
23 const std::string& outbound_endpoint,
24 uint16_t setup_port,
25 uint16_t inbound_port,
26 uint16_t outbound_port,
27 size_t io_threads,
28 E3Role role,
29 const PosixOptions& posix
30) {
31 std::unique_ptr<E3Connector> conn;
32 switch (link_layer) {
34#if LIBE3_HAS_ZMQ
35 conn = std::make_unique<ZmqE3Connector>(
36 transport_layer, setup_endpoint, inbound_endpoint, outbound_endpoint,
37 setup_port, inbound_port, outbound_port, io_threads
38 );
39 break;
40#else
41 // zmq_connector.cpp is not compiled in this configuration, so this
42 // is a configuration error at runtime rather than a link error at
43 // build time. E3LinkLayer::ZMQ stays in the enum either way: the
44 // value can arrive from a config file the build knows nothing about.
45 E3_LOG_ERROR("ConnFactory")
46 << "ZMQ link layer requested but libe3 was built with "
47 "LIBE3_ENABLE_ZMQ=OFF";
48 return nullptr;
49#endif
50
52 // One endpoint serves setup, inbound and outbound traffic.
53 conn = std::make_unique<PosixE3Connector>(transport_layer, setup_endpoint, setup_port, posix);
54 break;
55
56 default:
57 E3_LOG_ERROR("ConnFactory") << "Unsupported link layer: "
58 << static_cast<int>(link_layer);
59 return nullptr;
60 }
61 if (conn) conn->set_role(role);
62 return conn;
63}
64
65} // namespace libe3
Abstract E3 Connector interface for transport layer.
Logging facility for libe3.
#define E3_LOG_ERROR(component)
Definition logger.hpp:225
std::unique_ptr< E3Connector > create_connector(E3LinkLayer link_layer, E3TransportLayer transport_layer, const std::string &setup_endpoint, const std::string &inbound_endpoint, const std::string &outbound_endpoint, uint16_t setup_port, uint16_t inbound_port, uint16_t outbound_port, size_t io_threads=2, E3Role role=E3Role::RAN, const PosixOptions &posix=PosixOptions{})
Factory function to create appropriate connector.
E3TransportLayer
Transport layer types (matches Python E3TransportLayer).
Definition types.hpp:85
E3Role
Role this E3 endpoint plays in the protocol.
Definition types.hpp:77
E3LinkLayer
Link layer types (matches Python E3LinkLayer).
Definition types.hpp:62
@ POSIX
POSIX socket-based transport.
Definition types.hpp:64
@ ZMQ
ZeroMQ-based transport.
Definition types.hpp:63
POSIX socket-based E3 Connector.
Socket and admission options of the POSIX link.
ZeroMQ-based E3 Connector.