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 // database id
15 WriteValue<uint32_t>(OutFile, this->DatabaseId);
16 WriteValue<VehicleDoorType>(OutFile, this->Doors);
17 WriteValue<bool>(OutFile, this->bIsOpen);
18}
19void CarlaRecorderDoorVehicle::Read(std::istream &InFile)
20{
21 // database id
22 ReadValue<uint32_t>(InFile, this->DatabaseId);
23 ReadValue<VehicleDoorType>(InFile, this->Doors);
24 ReadValue<bool>(InFile, this->bIsOpen);
25}
26
27// ---------------------------------------------
28
30{
31 Vehicles.clear();
32}
33
38
39void CarlaRecorderDoorVehicles::Write(std::ostream &OutFile)
40{
41 // write the packet id
42 WriteValue<char>(OutFile, static_cast<char>(CarlaRecorderPacketId::VehicleDoor));
43
44 // write a dummy packet size
45 uint32_t Total = 2 + Vehicles.size() * sizeof(CarlaRecorderDoorVehicle);
46 WriteValue<uint32_t>(OutFile, Total);
47
48 // write total records
49 Total = Vehicles.size();
50 WriteValue<uint16_t>(OutFile, Total);
51
52 for (auto& Vehicle : Vehicles)
53 {
54 Vehicle.Write(OutFile);
55 }
56}
57
58void CarlaRecorderDoorVehicles::Read(std::istream &InFile)
59{
60 uint16_t Total;
61 CarlaRecorderDoorVehicle DoorVehicle;
62
63 // read Total walkers
64 ReadValue<uint16_t>(InFile, Total);
65 for (uint16_t i = 0; i < Total; ++i)
66 {
67 DoorVehicle.Read(InFile);
68 Add(DoorVehicle);
69 }
70}
71
72const std::vector<CarlaRecorderDoorVehicle>& CarlaRecorderDoorVehicles::GetDoorVehicles()
73{
74 return Vehicles;
75}
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()