CARLA
 
载入中...
搜索中...
未找到
DataStream.h
浏览该文件的文档.
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#pragma once
8
10
13#include <boost/optional.hpp>
15
16// =============================================================================
17// -- FDataStreamTmpl ----------------------------------------------------------
18// =============================================================================
19
20/// 用于将传感器数据发送到客户端的流式处理通道。每个传感器
21/// 都有自己的 FDataStream。但请注意,此类不提供 send 函数。
22/// 为了发送数据,需要使用 “MakeAsyncDataStream” 函数
23/// 创建一个 FAsyncDataStream。
24/// FAsyncDataStream 允许从任何线程发送数据。
25template <typename T>
27{
28public:
29
30 using StreamType = T;
31
32 FDataStreamTmpl() = default;
33
34 FDataStreamTmpl(StreamType InStream) : Stream(std::move(InStream)) {}
35
36 /// 创建 FAsyncDataStream 对象。
37 ///
38 /// @pre This functions needs to be called in the game-thread.
39 template <typename SensorT>
40 FAsyncDataStreamTmpl<T> MakeAsyncDataStream(const SensorT &Sensor, double Timestamp)
41 {
42 check(Stream.has_value());
43 return FAsyncDataStreamTmpl<T>{Sensor, Timestamp, *Stream};
44 }
45
47 {
48 return Stream.has_value();
49 }
50
51 /// 返回允许订阅此流的令牌。
52 auto GetToken() const
53 {
54 check(Stream.has_value());
55 return Stream->token();
56 }
57
58 uint64_t GetSensorType()
59 {
60 check(Stream.has_value());
61 return Stream->get_stream_id();
62 }
63
65 {
66 check(Stream.has_value());
67 return Stream->AreClientsListening();
68 }
69
70private:
71
72 boost::optional<StreamType> Stream;
73};
74
75// =============================================================================
76// -- FDataStream and FDataMultiStream -----------------------------------------
77// =============================================================================
78
80
异步数据。“发送”功能发送的数据被传递给 序列化程序在carla::sensor:SensorRegistry上注册了传感器 被顺流而下。
用于将传感器数据发送到客户端的流式处理通道。每个传感器 都有自己的 FDataStream。但请注意,此类不提供 send 函数。 为了发送数据,需要使用 “MakeAsyncDataStream” 函...
Definition DataStream.h:27
FDataStreamTmpl()=default
bool IsStreamReady()
Definition DataStream.h:46
auto GetToken() const
返回允许订阅此流的令牌。
Definition DataStream.h:52
uint64_t GetSensorType()
Definition DataStream.h:58
FDataStreamTmpl(StreamType InStream)
Definition DataStream.h:34
bool AreClientsListening()
Definition DataStream.h:64
boost::optional< StreamType > Stream
Definition DataStream.h:72
FAsyncDataStreamTmpl< T > MakeAsyncDataStream(const SensorT &Sensor, double Timestamp)
创建 FAsyncDataStream 对象。
Definition DataStream.h:40