CARLA
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
carla::streaming::detail::Dispatcher Class Reference

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}
 

Detailed Description

Keeps the mapping between streams and sessions.

Definition at line 28 of file Dispatcher.h.

Constructor & Destructor Documentation

◆ Dispatcher()

template<typename Protocol , typename EndPointType >
carla::streaming::detail::Dispatcher::Dispatcher ( const EndPoint< Protocol, EndPointType > &  ep)
inlineexplicit

Definition at line 32 of file Dispatcher.h.

◆ ~Dispatcher()

carla::streaming::detail::Dispatcher::~Dispatcher ( )

Definition at line 19 of file Dispatcher.cpp.

References _stream_map, and carla::log_error().

Member Function Documentation

◆ CloseStream()

void carla::streaming::detail::Dispatcher::CloseStream ( carla::streaming::detail::stream_id_type  id)

◆ DeregisterSession()

void carla::streaming::detail::Dispatcher::DeregisterSession ( std::shared_ptr< Session >  session)

◆ DisableForROS()

void carla::streaming::detail::Dispatcher::DisableForROS ( stream_id_type  sensor_id)
inline

Definition at line 78 of file Dispatcher.h.

References _mutex, and _stream_map.

Referenced by carla::streaming::low_level::Server< T >::DisableForROS().

◆ EnableForROS()

void carla::streaming::detail::Dispatcher::EnableForROS ( stream_id_type  sensor_id)
inline

Definition at line 70 of file Dispatcher.h.

References _mutex, and _stream_map.

Referenced by carla::streaming::low_level::Server< T >::EnableForROS().

◆ FindStreamAlias()

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().

◆ FindToken()

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().

◆ GetToken()

token_type carla::streaming::detail::Dispatcher::GetToken ( stream_id_type  sensor_id)

◆ IsEnabledForROS()

bool carla::streaming::detail::Dispatcher::IsEnabledForROS ( stream_id_type  sensor_id)
inline

Definition at line 86 of file Dispatcher.h.

References _mutex, and _stream_map.

Referenced by carla::streaming::low_level::Server< T >::IsEnabledForROS().

◆ MakeStream()

carla::streaming::Stream carla::streaming::detail::Dispatcher::MakeStream ( )

◆ RegisterSession()

bool carla::streaming::detail::Dispatcher::RegisterSession ( std::shared_ptr< Session >  session)

◆ RemoveStreamAlias()

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().

◆ ResolveSessionStreamId()

std::optional< stream_id_type > carla::streaming::detail::Dispatcher::ResolveSessionStreamId ( stream_id_type  session_stream_id) const
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().

◆ SetROS2TopicVisibilityDefaultEnabled()

void carla::streaming::detail::Dispatcher::SetROS2TopicVisibilityDefaultEnabled ( bool  enabled)
inline

◆ SetSessionsUseStreamAliases()

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().

◆ SetStreamAlias()

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().

Member Data Documentation

◆ _cached_token

token_type carla::streaming::detail::Dispatcher::_cached_token
private

Definition at line 104 of file Dispatcher.h.

Referenced by GetToken(), and MakeStream().

◆ _mutex

std::mutex carla::streaming::detail::Dispatcher::_mutex
private

◆ _session_streams

std::unordered_map<const Session *, std::weak_ptr<MultiStreamState> > carla::streaming::detail::Dispatcher::_session_streams
private

Definition at line 112 of file Dispatcher.h.

Referenced by DeregisterSession(), and RegisterSession().

◆ _sessions_use_stream_aliases

bool carla::streaming::detail::Dispatcher::_sessions_use_stream_aliases {false}
private

Definition at line 108 of file Dispatcher.h.

Referenced by ResolveSessionStreamId(), and SetSessionsUseStreamAliases().

◆ _stream_aliases

std::unordered_map<stream_id_type, stream_id_type> carla::streaming::detail::Dispatcher::_stream_aliases
private

◆ _stream_map

StreamMap carla::streaming::detail::Dispatcher::_stream_map
private

◆ _topic_visibility_default_enabled

bool carla::streaming::detail::Dispatcher::_topic_visibility_default_enabled {false}
private

Definition at line 116 of file Dispatcher.h.

Referenced by GetToken(), MakeStream(), and SetROS2TopicVisibilityDefaultEnabled().


The documentation for this class was generated from the following files: