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/// A streaming channel for sending sensor data to clients. Each sensor has its
21/// own FDataStream. Note however that this class does not provide a send
22/// function. In order to send data, a FAsyncDataStream needs to be created
23/// using "MakeAsyncDataStream" function. FAsyncDataStream allows sending data
24/// from any thread.
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 /// Create a FAsyncDataStream object.
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 /// Return the token that allows subscribing to this stream.
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
A streaming channel for sending sensor data to clients, supports sending data asynchronously.
A streaming channel for sending sensor data to clients.
Definition DataStream.h:27
FDataStreamTmpl()=default
bool IsStreamReady()
Definition DataStream.h:46
auto GetToken() const
Return the token that allows subscribing to this stream.
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)
Create a FAsyncDataStream object.
Definition DataStream.h:40