CARLA
incomingMessage.h
Go to the documentation of this file.
1 // Copyright (c) 2022 Computer Vision Center (CVC) at the Universitat Autonoma
2 // de Barcelona (UAB).
3 //
4 // This work is licensed under the terms of the MIT license.
5 // For a copy, see <https://opensource.org/licenses/MIT>.
6 
7 #include "carla/BufferPool.h"
8 #include "carla/Debug.h"
9 #include "carla/Exception.h"
10 #include "carla/Logging.h"
12 #include "carla/Time.h"
13 
14 #include <exception>
15 
16 namespace carla {
17 namespace multigpu {
18 
19  /// Helper for reading incoming TCP messages. Allocates the whole message in
20  /// a single buffer.
22  public:
23 
24  explicit IncomingMessage(Buffer &&buffer) : _buffer(std::move(buffer)) {}
25 
26  boost::asio::mutable_buffer size_as_buffer() {
27  return boost::asio::buffer(&_size, sizeof(_size));
28  }
29 
30  boost::asio::mutable_buffer buffer() {
31  DEBUG_ASSERT(_size > 0u);
33  return _buffer.buffer();
34  }
35 
36  auto size() const {
37  return _size;
38  }
39 
40  auto pop() {
41  return std::move(_buffer);
42  }
43 
44  private:
45 
47 
49  };
50 
51 
52 } // namespace multigpu
53 } // namespace carla
boost::asio::mutable_buffer size_as_buffer()
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
#define DEBUG_ASSERT(predicate)
Definition: Debug.h:66
uint32_t message_size_type
Definition: Types.h:20
void reset(size_type size)
Reset the size of this buffer.
Definition: carla/Buffer.h:252
Helper for reading incoming TCP messages.
boost::asio::const_buffer buffer() const noexcept
Make a boost::asio::buffer from this buffer.
Definition: carla/Buffer.h:176
carla::streaming::detail::message_size_type _size
boost::asio::mutable_buffer buffer()
A piece of raw data.
Definition: carla/Buffer.h:42