CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
streaming
detail
Token.cpp
Go to the documentation of this file.
1
// Copyright (c) 2026 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/streaming/detail/Token.h
"
8
9
#include "
carla/Exception.h
"
10
11
#include <cstring>
12
#include <exception>
13
14
namespace
carla
{
15
namespace
streaming
{
16
namespace
detail
{
17
18
void
token_type::set_address
(
const
boost::asio::ip::address &addr) {
19
if
(addr.is_v4()) {
20
_token
.
address_type
=
token_data::address::ip_v4
;
21
_token
.
address
.v4 = addr.to_v4().to_bytes();
22
}
else
if
(addr.is_v6()) {
23
_token
.
address_type
=
token_data::address::ip_v6
;
24
_token
.
address
.v6 = addr.to_v6().to_bytes();
25
}
else
{
26
throw_exception
(std::invalid_argument(
"invalid ip address!"
));
27
}
28
}
29
30
token_type::token_type
(
const
Token
&rhs) {
31
std::memcpy(&
_token
, &rhs.
data
[0u],
sizeof
(
_token
));
32
}
33
34
token_type::operator
Token
()
const
{
35
Token
token;
36
std::memcpy(&token.
data
[0u], &
_token
, token.
data
.size());
37
return
token;
38
}
39
40
boost::asio::ip::address
token_type::get_address
()
const
{
41
if
(
_token
.
address_type
==
token_data::address::ip_v4
) {
42
return
boost::asio::ip::address_v4(
_token
.
address
.v4);
43
}
44
return
boost::asio::ip::address_v6(
_token
.
address
.v6);
45
}
46
47
}
// namespace detail
48
}
// namespace streaming
49
}
// namespace carla
Exception.h
carla::streaming::Token
A token that uniquely identify a stream.
Definition
Token.h:17
carla::streaming::Token::data
std::array< unsigned char, 24u > data
Definition
Token.h:20
carla::streaming::detail::token_type::get_address
boost::asio::ip::address get_address() const
Definition
Token.cpp:40
carla::streaming::detail::token_type::token_type
token_type()=default
carla::streaming::detail::token_type::set_address
void set_address(const boost::asio::ip::address &addr)
Definition
Token.cpp:18
carla::streaming::detail::token_type::_token
token_data _token
Definition
detail/Token.h:175
Token.h
carla::streaming::detail
Definition
Dispatcher.cpp:17
carla::streaming
Definition
client/detail/Client.h:61
carla
This file contains definitions of common data structures used in traffic manager.
Definition
SignComponent.h:21
carla::throw_exception
void throw_exception(const ExceptionT &e)
Templated on the static type so the thrown object keeps its dynamic type: taking a const std::excepti...
Definition
Exception.h:44
carla::streaming::detail::token_data::address_type
enum carla::streaming::detail::token_data::address address_type
carla::streaming::detail::token_data::address
address
Definition
detail/Token.h:35
carla::streaming::detail::token_data::address::ip_v6
@ ip_v6
Definition
detail/Token.h:38
carla::streaming::detail::token_data::address::ip_v4
@ ip_v4
Definition
detail/Token.h:37
Generated by
1.18.0