CARLA
 
载入中...
搜索中...
未找到
CarlaRecorderState.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
7#include "CarlaRecorder.h"
10
11void CarlaRecorderStateTrafficLight::Write(std::ostream &OutFile)
12{
13 WriteValue<uint32_t>(OutFile, this->DatabaseId);
14 WriteValue<bool>(OutFile, this->IsFrozen);
15 WriteValue<float>(OutFile, this->ElapsedTime);
16 WriteValue<char>(OutFile, this->State);
17}
18
19void CarlaRecorderStateTrafficLight::Read(std::istream &InFile)
20{
21 ReadValue<uint32_t>(InFile, this->DatabaseId);
22 ReadValue<bool>(InFile, this->IsFrozen);
23 ReadValue<float>(InFile, this->ElapsedTime);
24 ReadValue<char>(InFile, this->State);
25}
26
27// ---------------------------------------------
28
30{
31 StatesTrafficLights.clear();
32}
33
38
39void CarlaRecorderStates::Write(std::ostream &OutFile)
40{
41 // write the packet id
42 WriteValue<char>(OutFile, static_cast<char>(CarlaRecorderPacketId::State));
43
44 // write the packet size
45 uint32_t Total = 2 + StatesTrafficLights.size() * sizeof(CarlaRecorderStateTrafficLight);
46 WriteValue<uint32_t>(OutFile, Total);
47
48 // write total records
49 Total = StatesTrafficLights.size();
50 WriteValue<uint16_t>(OutFile, Total);
51
52 for (uint16_t i = 0; i < Total; ++i)
53 {
54 StatesTrafficLights[i].Write(OutFile);
55 }
56}
57
58void CarlaRecorderStates::Read(std::istream &InFile)
59{
60 uint16_t i, Total;
61 CarlaRecorderStateTrafficLight StateTrafficLight;
62
63 // read Total traffic light states
64 ReadValue<uint16_t>(InFile, Total);
65 for (i = 0; i < Total; ++i)
66 {
67 StateTrafficLight.Read(InFile);
68 Add(StateTrafficLight);
69 }
70}
71
72const std::vector<CarlaRecorderStateTrafficLight>& CarlaRecorderStates::GetStates()
73{
75}
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderStateTrafficLight &State)
std::vector< CarlaRecorderStateTrafficLight > StatesTrafficLights
void Read(std::istream &InFile)
const std::vector< CarlaRecorderStateTrafficLight > & GetStates()
void Write(std::ostream &OutFile)
void Read(std::istream &InFile)