Program Listing for File fastdds_endpoint.hpp
↰ Return to documentation for file (include/holoscan/pubsub/fastdds/pubsub/fastdds_endpoint.hpp)
/*
* SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef HOLOSCAN_PUBSUB_FASTDDS_PUBSUB_FASTDDS_ENDPOINT_HPP
#define HOLOSCAN_PUBSUB_FASTDDS_PUBSUB_FASTDDS_ENDPOINT_HPP
#include <cstdint>
#include <vector>
#include <holoscan/core/endpoint.hpp>
#include <holoscan/core/errors.hpp>
#include <holoscan/core/expected.hpp>
namespace holoscan {
class FastDdsEndpoint : public holoscan::Endpoint {
public:
explicit FastDdsEndpoint(std::vector<uint8_t>* output_buffer);
FastDdsEndpoint(uint8_t* buffer, size_t buffer_size);
explicit FastDdsEndpoint(const std::vector<uint8_t>* input_buffer);
~FastDdsEndpoint() override = default;
// Delete copy operations (non-owning pointer semantics)
FastDdsEndpoint(const FastDdsEndpoint&) = delete;
FastDdsEndpoint& operator=(const FastDdsEndpoint&) = delete;
// Allow move operations
FastDdsEndpoint(FastDdsEndpoint&&) = default;
FastDdsEndpoint& operator=(FastDdsEndpoint&&) = default;
//----------------------------------------------------------------------------
// holoscan::Endpoint Interface
//----------------------------------------------------------------------------
bool is_write_available() override;
bool is_read_available() override;
expected<size_t, RuntimeError> write(const void* data, size_t size) override;
expected<size_t, RuntimeError> read(void* data, size_t size) override;
expected<void, RuntimeError> write_ptr(const void* pointer, size_t size,
holoscan::MemoryStorageType type) override;
//----------------------------------------------------------------------------
// FastDdsEndpoint-specific Methods
//----------------------------------------------------------------------------
void reset_read_position();
size_t read_position() const { return read_position_; }
size_t size() const;
size_t bytes_remaining() const;
size_t bytes_written() const;
bool is_write_mode() const { return output_buffer_ != nullptr || raw_output_buffer_ != nullptr; }
bool is_read_mode() const { return input_buffer_ != nullptr; }
private:
std::vector<uint8_t>* output_buffer_ = nullptr;
uint8_t* raw_output_buffer_ = nullptr;
size_t raw_buffer_size_ = 0;
size_t write_position_ = 0;
const std::vector<uint8_t>* input_buffer_ = nullptr;
size_t read_position_ = 0;
};
} // namespace holoscan
#endif// HOLOSCAN_PUBSUB_FASTDDS_PUBSUB_FASTDDS_ENDPOINT_HPP