CARLA
 
载入中...
搜索中...
未找到
EpisodeProxy.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
11#include <cstdint>
12
13namespace carla {
14namespace client {
15namespace detail {
16
17 class Simulator;
18
20 using Shared = std::shared_ptr<Simulator>;
22 using Weak = std::weak_ptr<Simulator>;
23 };
24
25 /// Provides access to the Simulator during a given episode. After the episode
26 /// is ended any access to the simulator throws an std::runtime_error.
27 template <typename PointerT>
29 public:
30
32
33 EpisodeProxyImpl() = default;
34
36
37 template <typename T>
41
42 auto GetId() const noexcept {
43 return _episode_id;
44 }
45
46 SharedPtrType TryLock() const noexcept;
47
48 /// Same as TryLock but never return nullptr.
49 ///
50 /// @throw std::runtime_error if episode is gone.
51 SharedPtrType Lock() const;
52
53 bool IsValid() const noexcept {
54 return TryLock() != nullptr;
55 }
56
57 void Clear() noexcept;
58
59 private:
60
61 template <typename T>
62 friend class EpisodeProxyImpl;
63
64 uint64_t _episode_id;
65
66 PointerT _simulator;
67 };
68
70
72
73} // namespace detail
74} // namespace client
75} // namespace carla
A very simple atomic shared ptr with release-acquire memory order.
Provides access to the Simulator during a given episode.
EpisodeProxyPointerType::Shared SharedPtrType
SharedPtrType TryLock() const noexcept
EpisodeProxyImpl(EpisodeProxyImpl< T > other)
SharedPtrType Lock() const
Same as TryLock but never return nullptr.
EpisodeProxyImpl< EpisodeProxyPointerType::Weak > WeakEpisodeProxy
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133