CARLA
载入中...
搜索中...
未找到
LibCarla
source
carla
road
LaneSectionMap.h
浏览该文件的文档.
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
7
#pragma once
8
9
#include "
carla/NonCopyable.h
"
// 引入不可复制的基类
10
#include "
carla/road/LaneSection.h
"
// 引入车道段的头文件
11
12
#include <map>
13
#include <unordered_map>
14
15
namespace
carla
{
16
namespace
road {
17
18
// LaneSectionMap 类用于管理车道段的映射
19
class
LaneSectionMap
20
:
private
std::multimap<double, LaneSection>,
// 继承自多重映射,键为double类型(位置),值为LaneSection对象
21
private
MovableNonCopyable
{
// 继承自不可复制的可移动类
22
using
Super
= std::multimap<double, LaneSection>;
// 定义父类类型别名
23
public
:
24
25
// 添加新的LaneSection并返回其引用
26
LaneSection
&
Emplace
(
SectionId
id
,
double
s) {
27
// 在多重映射中插入LaneSection,并获取其引用
28
LaneSection
&result = Super::emplace(s,
LaneSection
{id, s})->second;
29
// 同时在_id映射中记录该LaneSection的指针
30
_by_id
.emplace(result.
GetId
(), &result);
31
return
result;
// 返回LaneSection的引用
32
}
33
34
// 根据ID获取LaneSection的引用
35
LaneSection
&
GetById
(
SectionId
id
) {
36
return
*
_by_id
.at(
id
);
// 返回对应ID的LaneSection的引用
37
}
38
39
// 常量版本,根据ID获取LaneSection的引用
40
const
LaneSection
&
GetById
(
SectionId
id
)
const
{
41
return
*
_by_id
.at(
id
);
// 返回对应ID的LaneSection的引用
42
}
43
44
// 公开父类中的一些方法
45
using
Super::find;
// 查找功能
46
using
Super::upper_bound;
// 获取大于给定值的第一个元素
47
using
Super::lower_bound;
// 获取大于等于给定值的第一个元素
48
49
// 迭代器相关功能
50
using
Super::begin;
// 返回迭代器到首元素
51
using
Super::rbegin;
// 返回反向迭代器到末尾元素
52
using
Super::end;
// 返回迭代器到尾后元素
53
using
Super::rend;
// 返回反向迭代器到首前元素
54
55
private
:
56
// 通过ID快速查找LaneSection的哈希映射
57
std::unordered_map<SectionId, LaneSection *>
_by_id
;
58
};
59
60
}
// namespace road
61
}
// namespace carla
LaneSection.h
NonCopyable.h
carla::MovableNonCopyable
这个类用于禁止拷贝构造函数和赋值操作,但允许移动构造函数和赋值操作
Definition
LibCarla/source/carla/NonCopyable.h:27
carla::road::LaneSectionMap
Definition
LaneSectionMap.h:21
carla::road::LaneSectionMap::Super
std::multimap< double, LaneSection > Super
Definition
LaneSectionMap.h:22
carla::road::LaneSectionMap::GetById
const LaneSection & GetById(SectionId id) const
Definition
LaneSectionMap.h:40
carla::road::LaneSectionMap::_by_id
std::unordered_map< SectionId, LaneSection * > _by_id
Definition
LaneSectionMap.h:57
carla::road::LaneSectionMap::Emplace
LaneSection & Emplace(SectionId id, double s)
Definition
LaneSectionMap.h:26
carla::road::LaneSectionMap::GetById
LaneSection & GetById(SectionId id)
Definition
LaneSectionMap.h:35
carla::road::LaneSection
Definition
LaneSection.h:24
carla::road::LaneSection::GetId
SectionId GetId() const
Definition
LaneSection.cpp:27
carla::road::SectionId
uint32_t SectionId
Definition
RoadTypes.h:29
carla
CARLA模拟器的主命名空间。
Definition
Carla.cpp:139
制作者
1.10.0