CARLA
Loading...
Searching...
No Matches
carla::client::detail::CachedActorList Class Reference

Keeps a list of actor descriptions to avoid requesting each time the descriptions to the server. More...

#include <CachedActorList.h>

Inheritance diagram for carla::client::detail::CachedActorList:

Public Member Functions

void Clear ()
std::optional< rpc::Actor > GetActorById (ActorId id) const
 Retrieve the actor matching id, or empty optional if actor is not cached.
template<typename RangeT>
std::vector< rpc::Actor > GetActorsById (const RangeT &range) const
 Retrieve the actors matching the ids in range.
template<typename RangeT>
std::vector< ActorId > GetMissingIds (const RangeT &range) const
 Return the actor ids present in range that haven't been added to this list.
void Insert (rpc::Actor actor)
 Inserts an actor into the list.
template<typename RangeT>
void InsertRange (RangeT range)
 Inserts a range containing actors.

Private Attributes

std::unordered_map< ActorId, rpc::Actor > _actors
std::mutex _mutex

Additional Inherited Members

Private Member Functions inherited from carla::MovableNonCopyable
 MovableNonCopyable ()=default
 MovableNonCopyable (const MovableNonCopyable &)=delete
 MovableNonCopyable (MovableNonCopyable &&)=default
MovableNonCopyable & operator= (const MovableNonCopyable &)=delete
MovableNonCopyable & operator= (MovableNonCopyable &&)=default

Detailed Description

Keeps a list of actor descriptions to avoid requesting each time the descriptions to the server.

Todo
Dead actors are never removed from the list.

Definition at line 30 of file CachedActorList.h.

Member Function Documentation

◆ Clear()

void carla::client::detail::CachedActorList::Clear ( )
inline

Definition at line 119 of file CachedActorList.h.

References _actors, and _mutex.

Referenced by carla::client::detail::Episode::OnEpisodeStarted().

◆ GetActorById()

std::optional< rpc::Actor > carla::client::detail::CachedActorList::GetActorById ( ActorId id) const
inline

Retrieve the actor matching id, or empty optional if actor is not cached.

Definition at line 96 of file CachedActorList.h.

References _actors, and _mutex.

Referenced by carla::client::detail::Episode::GetActorById().

◆ GetActorsById()

template<typename RangeT>
std::vector< rpc::Actor > carla::client::detail::CachedActorList::GetActorsById ( const RangeT & range) const
inline

Retrieve the actors matching the ids in range.

Definition at line 106 of file CachedActorList.h.

References _actors, and _mutex.

Referenced by carla::client::detail::GetActorsById_Impl().

◆ GetMissingIds()

template<typename RangeT>
std::vector< ActorId > carla::client::detail::CachedActorList::GetMissingIds ( const RangeT & range) const
inline

Return the actor ids present in range that haven't been added to this list.

Definition at line 86 of file CachedActorList.h.

References _actors, and _mutex.

Referenced by carla::client::detail::GetActorsById_Impl().

◆ Insert()

void carla::client::detail::CachedActorList::Insert ( rpc::Actor actor)
inline

Inserts an actor into the list.

Definition at line 66 of file CachedActorList.h.

References _actors, _mutex, and carla::rpc::Actor::id.

Referenced by carla::client::detail::Episode::GetActorById(), and carla::client::detail::Episode::RegisterActor().

◆ InsertRange()

template<typename RangeT>
void carla::client::detail::CachedActorList::InsertRange ( RangeT range)
inline

Inserts a range containing actors.

Definition at line 73 of file CachedActorList.h.

References _actors, and _mutex.

Referenced by carla::client::detail::GetActorsById_Impl().

Member Data Documentation

◆ _actors

std::unordered_map<ActorId, rpc::Actor> carla::client::detail::CachedActorList::_actors
private

Definition at line 59 of file CachedActorList.h.

Referenced by Clear(), GetActorById(), GetActorsById(), GetMissingIds(), Insert(), and InsertRange().

◆ _mutex

std::mutex carla::client::detail::CachedActorList::_mutex
mutableprivate

Definition at line 57 of file CachedActorList.h.

Referenced by Clear(), GetActorById(), GetActorsById(), GetMissingIds(), Insert(), and InsertRange().


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