CARLA
 
载入中...
搜索中...
未找到
CarlaRecorderDoorVehicle.cpp
浏览该文件的文档.
1// Copyright (c) 2023 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#include "CarlaRecorder.h"
10
11
12void CarlaRecorderDoorVehicle::Write(std::ostream &OutFile)
13{
14 // 写入数据库 ID,类型为 uint32_t(无符号 32 位整数)
15 WriteValue<uint32_t>(OutFile, this->DatabaseId);
16
17 // 写入车辆门的类型,类型为 VehicleDoorType(自定义的枚举或类,表示车辆门的类型)
18 WriteValue<VehicleDoorType>(OutFile, this->Doors);
19
20 // 写入一个布尔值,表示门是否打开,类型为 bool(布尔值)
21 WriteValue<bool>(OutFile, this->bIsOpen);
22}
23
24void CarlaRecorderDoorVehicle::Read(std::istream &InFile)
25{
26 // database id
27 ReadValue<uint32_t>(InFile, this->DatabaseId);
28 ReadValue<VehicleDoorType>(InFile, this->Doors);
29 ReadValue<bool>(InFile, this->bIsOpen);
30}
31
32// ---------------------------------------------
33
35{
36 Vehicles.clear();
37}
38
43
44void CarlaRecorderDoorVehicles::Write(std::ostream &OutFile)
45{
46 // write the packet id
47 WriteValue<char>(OutFile, static_cast<char>(CarlaRecorderPacketId::VehicleDoor));
48
49 // write a dummy packet size
50 uint32_t Total = 2 + Vehicles.size() * sizeof(CarlaRecorderDoorVehicle);
51 WriteValue<uint32_t>(OutFile, Total);
52
53 // write total records
54 Total = Vehicles.size();
55 WriteValue<uint16_t>(OutFile, Total);
56
57 for (auto& Vehicle : Vehicles)
58 {
59 Vehicle.Write(OutFile);
60 }
61}
62
63void CarlaRecorderDoorVehicles::Read(std::istream &InFile)
64{
65 uint16_t Total;
66 CarlaRecorderDoorVehicle DoorVehicle;
67
68 // read Total walkers
69 ReadValue<uint16_t>(InFile, Total);
70 for (uint16_t i = 0; i < Total; ++i)
71 {
72 DoorVehicle.Read(InFile);
73 Add(DoorVehicle);
74 }
75}
76
77const std::vector<CarlaRecorderDoorVehicle>& CarlaRecorderDoorVehicles::GetDoorVehicles()
78{
79 return Vehicles;
80}
void Write(std::ostream &OutFile)
void Read(std::istream &InFile)
void Write(std::ostream &OutFile)
std::vector< CarlaRecorderDoorVehicle > Vehicles
void Add(const CarlaRecorderDoorVehicle &InObj)
void Read(std::istream &InFile)
const std::vector< CarlaRecorderDoorVehicle > & GetDoorVehicles()