|
CARLA
|
Keeps the mapping between streams and sessions. More...
#include <Dispatcher.h>
Public Member Functions | |
| void | CloseStream (carla::streaming::detail::stream_id_type id) |
| void | DeregisterSession (std::shared_ptr< Session > session) |
| void | DisableForROS (stream_id_type sensor_id) |
| template<typename Protocol , typename EndPointType > | |
| Dispatcher (const EndPoint< Protocol, EndPointType > &ep) | |
| void | EnableForROS (stream_id_type sensor_id) |
| std::optional< stream_id_type > | FindStreamAlias (stream_id_type alias) |
| std::optional< token_type > | FindToken (stream_id_type stream_id) |
| Like GetToken(), but returns std::nullopt for an unknown stream_id instead of creating an empty stream for it. | |
| token_type | GetToken (stream_id_type sensor_id) |
| bool | IsEnabledForROS (stream_id_type sensor_id) |
| carla::streaming::Stream | MakeStream () |
| bool | RegisterSession (std::shared_ptr< Session > session) |
| void | RemoveStreamAlias (stream_id_type alias) |
| void | SetROS2TopicVisibilityDefaultEnabled (bool enabled) |
| void | SetSessionsUseStreamAliases (bool enabled) |
| When enabled, a session subscribes through an alias (see SetStreamAlias) and a stream id without an alias is refused, since aliases and local stream ids are separate id spaces that may overlap. | |
| void | SetStreamAlias (stream_id_type alias, stream_id_type stream_id) |
| Routes sessions subscribing to alias to the local stream stream_id. | |
| ~Dispatcher () | |
Private Member Functions | |
| std::optional< stream_id_type > | ResolveSessionStreamId (stream_id_type session_stream_id) const |
| Stream a session subscribing to session_stream_id belongs to. | |
Private Attributes | |
| token_type | _cached_token |
| std::mutex | _mutex |
| std::unordered_map< const Session *, std::weak_ptr< MultiStreamState > > | _session_streams |
| bool | _sessions_use_stream_aliases {false} |
| std::unordered_map< stream_id_type, stream_id_type > | _stream_aliases |
| StreamMap | _stream_map |
| bool | _topic_visibility_default_enabled {false} |
Keeps the mapping between streams and sessions.
Definition at line 28 of file Dispatcher.h.
|
inlineexplicit |
Definition at line 32 of file Dispatcher.h.
| carla::streaming::detail::Dispatcher::~Dispatcher | ( | ) |
Definition at line 19 of file Dispatcher.cpp.
References _stream_map, and carla::log_error().
| void carla::streaming::detail::Dispatcher::CloseStream | ( | carla::streaming::detail::stream_id_type | id | ) |
Definition at line 63 of file Dispatcher.cpp.
References _mutex, _stream_map, and carla::log_debug().
Referenced by carla::streaming::low_level::Server< T >::CloseStream().
| void carla::streaming::detail::Dispatcher::DeregisterSession | ( | std::shared_ptr< Session > | session | ) |
Definition at line 108 of file Dispatcher.cpp.
References _mutex, _session_streams, _stream_map, DEBUG_ASSERT, and carla::log_debug().
Referenced by carla::streaming::low_level::Server< T >::StartServer().
|
inline |
Definition at line 78 of file Dispatcher.h.
References _mutex, and _stream_map.
Referenced by carla::streaming::low_level::Server< T >::DisableForROS().
|
inline |
Definition at line 70 of file Dispatcher.h.
References _mutex, and _stream_map.
Referenced by carla::streaming::low_level::Server< T >::EnableForROS().
| std::optional< stream_id_type > carla::streaming::detail::Dispatcher::FindStreamAlias | ( | stream_id_type | alias | ) |
Definition at line 184 of file Dispatcher.cpp.
References _mutex, and _stream_aliases.
Referenced by carla::streaming::low_level::Server< T >::FindStreamAlias().
| std::optional< token_type > carla::streaming::detail::Dispatcher::FindToken | ( | stream_id_type | stream_id | ) |
Like GetToken(), but returns std::nullopt for an unknown stream_id instead of creating an empty stream for it.
Definition at line 158 of file Dispatcher.cpp.
References _mutex, and _stream_map.
Referenced by carla::streaming::low_level::Server< T >::FindToken().
| token_type carla::streaming::detail::Dispatcher::GetToken | ( | stream_id_type | sensor_id | ) |
Definition at line 127 of file Dispatcher.cpp.
References _cached_token, _mutex, _stream_map, _topic_visibility_default_enabled, carla::streaming::detail::token_type::get_port(), carla::streaming::detail::token_type::get_stream_id(), carla::log_debug(), and carla::streaming::detail::token_type::set_stream_id().
Referenced by carla::streaming::low_level::Server< T >::GetToken().
|
inline |
Definition at line 86 of file Dispatcher.h.
References _mutex, and _stream_map.
Referenced by carla::streaming::low_level::Server< T >::IsEnabledForROS().
| carla::streaming::Stream carla::streaming::detail::Dispatcher::MakeStream | ( | ) |
Definition at line 37 of file Dispatcher.cpp.
References _cached_token, _mutex, _stream_map, carla::streaming::detail::token_type::_token, _topic_visibility_default_enabled, carla::streaming::detail::token_type::get_stream_id(), carla::log_debug(), carla::streaming::detail::token_data::stream_id, and carla::throw_exception().
Referenced by carla::streaming::low_level::Server< T >::MakeStream(), TEST(), and TEST().
| bool carla::streaming::detail::Dispatcher::RegisterSession | ( | std::shared_ptr< Session > | session | ) |
Definition at line 88 of file Dispatcher.cpp.
References _mutex, _session_streams, _stream_map, DEBUG_ASSERT, carla::log_debug(), carla::log_error(), and ResolveSessionStreamId().
Referenced by carla::streaming::low_level::Server< T >::StartServer().
| void carla::streaming::detail::Dispatcher::RemoveStreamAlias | ( | stream_id_type | alias | ) |
Definition at line 179 of file Dispatcher.cpp.
References _mutex, and _stream_aliases.
Referenced by carla::streaming::low_level::Server< T >::RemoveStreamAlias().
|
private |
Stream a session subscribing to session_stream_id belongs to.
Definition at line 77 of file Dispatcher.cpp.
References _sessions_use_stream_aliases, and _stream_aliases.
Referenced by RegisterSession().
|
inline |
Definition at line 65 of file Dispatcher.h.
References _mutex, and _topic_visibility_default_enabled.
Referenced by carla::streaming::low_level::Server< T >::SetROS2TopicVisibilityDefaultEnabled().
| void carla::streaming::detail::Dispatcher::SetSessionsUseStreamAliases | ( | bool | enabled | ) |
When enabled, a session subscribes through an alias (see SetStreamAlias) and a stream id without an alias is refused, since aliases and local stream ids are separate id spaces that may overlap.
Definition at line 169 of file Dispatcher.cpp.
References _mutex, and _sessions_use_stream_aliases.
Referenced by carla::streaming::low_level::Server< T >::SetSessionsUseStreamAliases().
| void carla::streaming::detail::Dispatcher::SetStreamAlias | ( | stream_id_type | alias, |
| stream_id_type | stream_id | ||
| ) |
Routes sessions subscribing to alias to the local stream stream_id.
Definition at line 174 of file Dispatcher.cpp.
References _mutex, and _stream_aliases.
Referenced by carla::streaming::low_level::Server< T >::SetStreamAlias().
|
private |
Definition at line 104 of file Dispatcher.h.
Referenced by GetToken(), and MakeStream().
|
private |
Definition at line 102 of file Dispatcher.h.
Referenced by CloseStream(), DeregisterSession(), DisableForROS(), EnableForROS(), FindStreamAlias(), FindToken(), GetToken(), IsEnabledForROS(), MakeStream(), RegisterSession(), RemoveStreamAlias(), SetROS2TopicVisibilityDefaultEnabled(), SetSessionsUseStreamAliases(), and SetStreamAlias().
|
private |
Definition at line 112 of file Dispatcher.h.
Referenced by DeregisterSession(), and RegisterSession().
|
private |
Definition at line 108 of file Dispatcher.h.
Referenced by ResolveSessionStreamId(), and SetSessionsUseStreamAliases().
|
private |
Definition at line 110 of file Dispatcher.h.
Referenced by FindStreamAlias(), RemoveStreamAlias(), ResolveSessionStreamId(), and SetStreamAlias().
|
private |
Definition at line 106 of file Dispatcher.h.
Referenced by CloseStream(), DeregisterSession(), DisableForROS(), EnableForROS(), FindToken(), GetToken(), IsEnabledForROS(), MakeStream(), RegisterSession(), and ~Dispatcher().
|
private |
Definition at line 116 of file Dispatcher.h.
Referenced by GetToken(), MakeStream(), and SetROS2TopicVisibilityDefaultEnabled().