libe3 0.2.5
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) {
30 std::unique_ptr<E3Connector> conn;
31 switch (link_layer) {
33#if LIBE3_HAS_ZMQ
34 conn = std::make_unique<ZmqE3Connector>(
35 transport_layer, setup_endpoint, inbound_endpoint, outbound_endpoint,
36 setup_port, inbound_port, outbound_port, io_threads
37 );
38 break;
39#else
40 // zmq_connector.cpp is not compiled in this configuration, so this
41 // is a configuration error at runtime rather than a link error at
42 // build time. E3LinkLayer::ZMQ stays in the enum either way: the
43 // value can arrive from a config file the build knows nothing about.
44 E3_LOG_ERROR("ConnFactory")
45 << "ZMQ link layer requested but libe3 was built with "
46 "LIBE3_ENABLE_ZMQ=OFF";
47 return nullptr;
48#endif
49
51 conn = std::make_unique<PosixE3Connector>(
52 transport_layer, setup_endpoint, inbound_endpoint, outbound_endpoint,
53 setup_port, inbound_port, outbound_port
54 );
55 break;
56
57 default:
58 E3_LOG_ERROR("ConnFactory") << "Unsupported link layer: "
59 << static_cast<int>(link_layer);
60 return nullptr;
61 }
62 if (conn) conn->set_role(role);
63 return conn;
64}
65
66} // namespace libe3
Abstract E3 Connector interface for transport layer.
Logging facility for libe3.
#define E3_LOG_ERROR(component)
Definition logger.hpp:225
E3TransportLayer
Transport layer types (matches Python E3TransportLayer).
Definition types.hpp:83
E3Role
Role this E3 endpoint plays in the protocol.
Definition types.hpp:75
E3LinkLayer
Link layer types (matches Python E3LinkLayer).
Definition types.hpp:60
@ POSIX
POSIX socket-based transport.
Definition types.hpp:62
@ ZMQ
ZeroMQ-based transport.
Definition types.hpp:61
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)
Factory function to create appropriate connector.
POSIX socket-based E3 Connector.
ZeroMQ-based E3 Connector.