CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
Unreal
CarlaUnreal
Plugins
Carla
Source
Carla
Recorder
CarlaRecorderEventDel.cpp
Go to the documentation of this file.
1
// Copyright (c) 2026 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 "
CarlaRecorderEventDel.h
"
8
#include "
CarlaRecorder.h
"
9
#include "
CarlaRecorderHelpers.h
"
10
11
#include <algorithm>
12
#include <limits>
13
14
void
CarlaRecorderEventDel::Read
(std::istream &InFile)
15
{
16
// database id
17
ReadValue<uint32_t>
(InFile, this->
DatabaseId
);
18
}
19
void
CarlaRecorderEventDel::Write
(std::ostream &OutFile)
const
20
{
21
// database id
22
WriteValue<uint32_t>
(OutFile, this->
DatabaseId
);
23
}
24
25
//---------------------------------------------
26
27
void
CarlaRecorderEventsDel::Clear
(
void
)
28
{
29
Events
.clear();
30
}
31
32
void
CarlaRecorderEventsDel::Add
(
const
CarlaRecorderEventDel
&Event)
33
{
34
Events
.push_back(std::move(Event));
35
}
36
37
void
CarlaRecorderEventsDel::Write
(std::ostream &OutFile)
38
{
39
// write the packet id
40
WriteValue<char>
(OutFile,
static_cast<
char
>
(
CarlaRecorderPacketId::EventDel
));
41
42
std::streampos PosStart = OutFile.tellp();
43
44
// write a dummy packet size
45
uint32_t Total = 0;
46
WriteValue<uint32_t>
(OutFile, Total);
47
48
// write total records
49
Total = std::min<size_t>(
Events
.size(), std::numeric_limits<uint16_t>::max());
50
WriteValue<uint16_t>
(OutFile, Total);
51
52
for
(uint16_t i=0; i<Total; ++i)
53
{
54
Events
[i].Write(OutFile);
55
}
56
57
// write the real packet size
58
std::streampos PosEnd = OutFile.tellp();
59
Total = PosEnd - PosStart -
sizeof
(uint32_t);
60
OutFile.seekp(PosStart, std::ios::beg);
61
WriteValue<uint32_t>
(OutFile, Total);
62
OutFile.seekp(PosEnd, std::ios::beg);
63
}
64
65
void
CarlaRecorderEventsDel::Read
(std::istream &InFile)
66
{
67
uint16_t i, Total = 0;
68
CarlaRecorderEventDel
EventDel
;
69
70
// process destroy events
71
ReadValue<uint16_t>
(InFile, Total);
72
for
(i = 0; (i < Total) && InFile; ++i)
73
{
74
EventDel
.Read(InFile);
75
Add
(
EventDel
);
76
}
77
}
78
79
const
std::vector<CarlaRecorderEventDel>&
CarlaRecorderEventsDel::GetEvents
()
80
{
81
return
Events
;
82
}
CarlaRecorderEventDel.h
CarlaRecorderHelpers.h
WriteValue
void WriteValue(std::ostream &OutFile, const T &InObj)
Definition
CarlaRecorderHelpers.h:21
ReadValue
void ReadValue(std::istream &InFile, T &OutObj)
Definition
CarlaRecorderHelpers.h:60
CarlaRecorder.h
CarlaRecorderPacketId::EventDel
@ EventDel
Definition
CarlaRecorder.h:54
CarlaRecorderEventsDel::Add
void Add(const CarlaRecorderEventDel &Event)
Definition
CarlaRecorderEventDel.cpp:32
CarlaRecorderEventsDel::Clear
void Clear(void)
Definition
CarlaRecorderEventDel.cpp:27
CarlaRecorderEventsDel::GetEvents
const std::vector< CarlaRecorderEventDel > & GetEvents()
Definition
CarlaRecorderEventDel.cpp:79
CarlaRecorderEventsDel::Write
void Write(std::ostream &OutFile)
Definition
CarlaRecorderEventDel.cpp:37
CarlaRecorderEventsDel::Read
void Read(std::istream &InFile)
Definition
CarlaRecorderEventDel.cpp:65
CarlaRecorderEventsDel::Events
std::vector< CarlaRecorderEventDel > Events
Definition
CarlaRecorderEventDel.h:31
CarlaRecorderEventDel
Definition
CarlaRecorderEventDel.h:13
CarlaRecorderEventDel::Read
void Read(std::istream &InFile)
Definition
CarlaRecorderEventDel.cpp:14
CarlaRecorderEventDel::DatabaseId
uint32_t DatabaseId
Definition
CarlaRecorderEventDel.h:14
CarlaRecorderEventDel::Write
void Write(std::ostream &OutFile) const
Definition
CarlaRecorderEventDel.cpp:19
Generated by
1.18.0