CARLA
 
载入中...
搜索中...
未找到
CarlaRecorderEventDel.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 CarlaRecorderEventDel::Read(std::istream &InFile)
12{
13 // database id
14 ReadValue<uint32_t>(InFile, this->DatabaseId);
15}
16void CarlaRecorderEventDel::Write(std::ostream &OutFile) const
17{
18 // database id
19 WriteValue<uint32_t>(OutFile, this->DatabaseId);
20}
21
22//---------------------------------------------
23
25{
26 Events.clear();
27}
28
30{
31 Events.push_back(std::move(Event));
32}
33
34void CarlaRecorderEventsDel::Write(std::ostream &OutFile)
35{
36 // write the packet id
37 WriteValue<char>(OutFile, static_cast<char>(CarlaRecorderPacketId::EventDel));
38
39 std::streampos PosStart = OutFile.tellp();
40
41 // write a dummy packet size
42 uint32_t Total = 0;
43 WriteValue<uint32_t>(OutFile, Total);
44
45 // write total records
46 Total = Events.size();
47 WriteValue<uint16_t>(OutFile, Total);
48
49 for (uint16_t i=0; i<Total; ++i)
50 {
51 Events[i].Write(OutFile);
52 }
53
54 // write the real packet size
55 std::streampos PosEnd = OutFile.tellp();
56 Total = PosEnd - PosStart - sizeof(uint32_t);
57 OutFile.seekp(PosStart, std::ios::beg);
58 WriteValue<uint32_t>(OutFile, Total);
59 OutFile.seekp(PosEnd, std::ios::beg);
60}
61
62void CarlaRecorderEventsDel::Read(std::istream &InFile)
63{
64 uint16_t i, Total;
66
67 // process destroy events
68 ReadValue<uint16_t>(InFile, Total);
69 for (i = 0; i < Total; ++i)
70 {
71 EventDel.Read(InFile);
73 }
74}
75
76const std::vector<CarlaRecorderEventDel>& CarlaRecorderEventsDel::GetEvents()
77{
78 return Events;
79}
void Add(const CarlaRecorderEventDel &Event)
const std::vector< CarlaRecorderEventDel > & GetEvents()
void Write(std::ostream &OutFile)
void Read(std::istream &InFile)
std::vector< CarlaRecorderEventDel > Events
void Read(std::istream &InFile)
void Write(std::ostream &OutFile) const