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