CARLA
 
载入中...
搜索中...
未找到
CarlaRecorderLightVehicle.cpp
浏览该文件的文档.
1// Copyright (c) 2020 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 CarlaRecorderLightVehicle::Write(std::ostream &OutFile)
13{
14 // database id
15 WriteValue<uint32_t>(OutFile, this->DatabaseId);
16 WriteValue<VehicleLightStateType>(OutFile, this->State);
17}
18void CarlaRecorderLightVehicle::Read(std::istream &InFile)
19{
20 // database id
21 ReadValue<uint32_t>(InFile, this->DatabaseId);
22 ReadValue<VehicleLightStateType>(InFile, this->State);
23}
24
25// ---------------------------------------------
26
28{
29 Vehicles.clear();
30}
31
36
37void CarlaRecorderLightVehicles::Write(std::ostream &OutFile)
38{
39 // write the packet id
40 WriteValue<char>(OutFile, static_cast<char>(CarlaRecorderPacketId::VehicleLight));
41
42 // write a dummy packet size
43 uint32_t Total = 2 + Vehicles.size() * sizeof(CarlaRecorderLightVehicle);
44 WriteValue<uint32_t>(OutFile, Total);
45
46 // write total records
47 Total = Vehicles.size();
48 WriteValue<uint16_t>(OutFile, Total);
49
50 for (auto& Vehicle : Vehicles)
51 {
52 Vehicle.Write(OutFile);
53 }
54}
55
56void CarlaRecorderLightVehicles::Read(std::istream &InFile)
57{
58 uint16_t Total;
59 CarlaRecorderLightVehicle LightVehicle;
60
61 // read Total walkers
62 ReadValue<uint16_t>(InFile, Total);
63 for (uint16_t i = 0; i < Total; ++i)
64 {
65 LightVehicle.Read(InFile);
66 Add(LightVehicle);
67 }
68}
69
70const std::vector<CarlaRecorderLightVehicle>& CarlaRecorderLightVehicles::GetLightVehicles()
71{
72 return Vehicles;
73}
void Write(std::ostream &OutFile)
void Read(std::istream &InFile)
const std::vector< CarlaRecorderLightVehicle > & GetLightVehicles()
void Write(std::ostream &OutFile)
std::vector< CarlaRecorderLightVehicle > Vehicles
void Add(const CarlaRecorderLightVehicle &InObj)