libe3 0.2.5
C++ library for E3AP RAN vendor integration
Loading...
Searching...
No Matches
protobuf_encoder.hpp
Go to the documentation of this file.
1/**
2 * @file protobuf_encoder.hpp
3 * @brief Protocol Buffers encoder for E3AP PDUs
4 *
5 * SPDX-FileCopyrightText: Copyright (c) 2026 Northeastern University
6 * SPDX-License-Identifier: Apache-2.0
7 */
8
9#ifndef LIBE3_PROTOBUF_ENCODER_HPP
10#define LIBE3_PROTOBUF_ENCODER_HPP
11
12#include "libe3/e3_encoder.hpp"
13
14// Forward declaration of the generated protobuf message (defined in e3ap-1.0.0.pb.h).
15namespace libe3 {
16namespace e3ap {
17namespace v1 {
18class E3Pdu;
19}
20}
21}
22
23namespace libe3 {
24
25/**
26 * @brief Protocol Buffers encoder implementation
27 *
28 * Uses protoc-generated C++ code to encode/decode E3AP PDUs with Protocol
29 * Buffers wire format.
30 */
32public:
33 ProtobufE3Encoder() = default;
34 ~ProtobufE3Encoder() override = default;
35
36 // E3Encoder interface
37 EncodeResult<EncodedMessage> encode(const Pdu& pdu) override;
38 EncodeResult<Pdu> decode(const EncodedMessage& encoded) override;
39 EncodeResult<Pdu> decode(const uint8_t* data, size_t size) override;
40 EncodingFormat format() const noexcept override { return EncodingFormat::PROTOBUF; }
41
42private:
43 // Conversion helpers between the C++ Pdu struct and the generated message.
44 bool pdu_to_proto(const Pdu& pdu, e3ap::v1::E3Pdu& out) const;
45 Pdu proto_to_pdu(const e3ap::v1::E3Pdu& proto) const;
46};
47
48} // namespace libe3
49
50#endif // LIBE3_PROTOBUF_ENCODER_HPP
E3Encoder(const E3Encoder &)=delete
EncodingFormat format() const noexcept override
Get the encoding format.
~ProtobufE3Encoder() override=default
EncodeResult< Pdu > decode(const EncodedMessage &encoded) override
Decode bytes to a PDU.
EncodeResult< EncodedMessage > encode(const Pdu &pdu) override
Encode a PDU to bytes.
Abstract E3 Encoder interface for PDU encoding/decoding.
EncodingFormat
E3AP encoding formats supported by the library.
Definition types.hpp:51
@ PROTOBUF
Protocol Buffers encoding.
Definition types.hpp:54
tl::expected< T, ErrorCode > EncodeResult
Result type for encoding/decoding operations.
Encoded message wrapper.
Definition types.hpp:175
Generic E3AP PDU structure.
Definition types.hpp:345