CARLA
 
载入中...
搜索中...
未找到
ActorList.cpp
浏览该文件的文档.
1// Copyright (c) 2017 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
8
9#include "carla/StringUtil.h"
11
12#include <iterator>
13
14namespace carla {
15namespace client {
16
17 ActorList::ActorList(
19 std::vector<rpc::Actor> actors)
20 : _episode(std::move(episode)),
21 _actors(std::make_move_iterator(actors.begin()), std::make_move_iterator(actors.end())) {}
22
23 SharedPtr<Actor> ActorList::Find(const ActorId actor_id) const {
24 for (auto &actor : _actors) {
25 if (actor_id == actor.GetId()) {
26 return actor.Get(_episode);
27 }
28 }
29 return nullptr;
30 }
31
32 SharedPtr<ActorList> ActorList::Filter(const std::string &wildcard_pattern) const {
33 SharedPtr<ActorList> filtered (new ActorList(_episode, {}));
34 for (auto &&actor : _actors) {
35 if (StringUtil::Match(actor.GetTypeId(), wildcard_pattern)) {
36 filtered->_actors.push_back(actor);
37 }
38 }
39 return filtered;
40 }
41
42} // namespace client
43} // namespace carla
static bool Match(const char *str, const char *wildcard_pattern)
Match str with the Unix shell-style wildcard_pattern.
std::vector< detail::ActorVariant > _actors
Definition ActorList.h:68
detail::EpisodeProxy _episode
Definition ActorList.h:66
carla::SharedPtr< cc::ActorList > ActorList
Definition ALSM.h:33
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133
boost::shared_ptr< T > SharedPtr
Use this SharedPtr (boost::shared_ptr) to keep compatibility with boost::python, but it would be nice...
Definition Memory.h:20