CARLA
 
载入中...
搜索中...
未找到
CarlaRecorderFrameCounter.cpp
浏览该文件的文档.
1// Copyright (c) 2022 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
8#include "CarlaRecorder.h"
10
11void CarlaRecorderFrameCounter::Read(std::istream &InFile)
12{
13 ReadValue<uint64_t>(InFile, this->FrameCounter);
14}
15
16void CarlaRecorderFrameCounter::Write(std::ostream &OutFile)
17{
18 // 写入包 ID,类型为 char。静态转换为帧计数器的包类型
19 // `CarlaRecorderPacketId::FrameCounter` 应该是一个枚举值,表示这个数据包的类型是 "FrameCounter"
20 WriteValue<char>(OutFile, static_cast<char>(CarlaRecorderPacketId::FrameCounter));
21
22 // 写入包的大小,包的总大小为 uint64_t 类型的大小,即 8 字节
23 // `sizeof(uint64_t)` 返回的是 uint64_t 类型的字节大小,这里为 8
24 uint32_t Total = sizeof(uint64_t);
25 WriteValue<uint32_t>(OutFile, Total);
26
27 // 写入帧计数器的值,类型为 uint64_t(64 位无符号整数)
28 WriteValue<uint64_t>(OutFile, this->FrameCounter);
29}
30
void Write(std::ostream &OutFile)
void Read(std::istream &InFile)