Fast DDS  Version 3.6.1.0
Fast DDS
NetworkBuffer.hpp
1 // Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
19 #ifndef FASTDDS_RTPS_TRANSPORT__NETWORKBUFFER_HPP
20 #define FASTDDS_RTPS_TRANSPORT__NETWORKBUFFER_HPP
21 
22 #include <cstdint>
23 
24 namespace asio {
25 // Forward declaration of asio::const_buffer
26 class const_buffer;
27 } // namespace asio
28 
29 namespace eprosima {
30 namespace fastdds {
31 namespace rtps {
32 
37 struct NetworkBuffer final
38 {
40  const void* buffer = nullptr;
42  uint32_t size = 0;
43 
44  NetworkBuffer() = default;
45 
47  const void* ptr,
48  uint32_t s)
49  : buffer(ptr)
50  , size(s)
51  {
52  }
53 
55  operator asio::const_buffer() const;
56 };
57 
58 } // namespace rtps
59 } // namespace fastdds
60 } // namespace eprosima
61 
62 #endif // FASTDDS_RTPS_TRANSPORT__NETWORKBUFFER_HPP
Definition: NetworkBuffer.hpp:24
A slice of data to be sent to one or more transports.
Definition: NetworkBuffer.hpp:38
const void * buffer
Pointer to the buffer where the data is stored.
Definition: NetworkBuffer.hpp:40
uint32_t size
Number of bytes to use starting at buffer.
Definition: NetworkBuffer.hpp:42
NetworkBuffer(const void *ptr, uint32_t s)
Definition: NetworkBuffer.hpp:46