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