CARLA
rpc/Client.h
Go to the documentation of this file.
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 
9 #include "carla/rpc/Metadata.h"
10 
11 #include <rpc/client.h>
12 
13 namespace carla {
14 namespace rpc {
15 
16  class Client {
17  public:
18 
19  template <typename... Args>
20  explicit Client(Args &&... args)
21  : _client(std::forward<Args>(args)...) {}
22 
23  void set_timeout(int64_t value) {
24  _client.set_timeout(value);
25  }
26 
27  auto get_timeout() const {
28  return _client.get_timeout();
29  }
30 
31  template <typename... Args>
32  auto call(const std::string &function, Args &&... args) {
33  return _client.call(function, Metadata::MakeSync(), std::forward<Args>(args)...);
34  }
35 
36  template <typename... Args>
37  void async_call(const std::string &function, Args &&... args) {
38  _client.async_call(function, Metadata::MakeAsync(), std::forward<Args>(args)...);
39  }
40 
41  private:
42 
43  ::rpc::client _client;
44  };
45 
46 } // namespace rpc
47 } // namespace carla
static Metadata MakeSync()
Definition: Metadata.h:20
void set_timeout(int64_t value)
Definition: rpc/Client.h:23
void async_call(const std::string &function, Args &&... args)
Definition: rpc/Client.h:37
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
auto call(const std::string &function, Args &&... args)
Definition: rpc/Client.h:32
auto get_timeout() const
Definition: rpc/Client.h:27
Client(Args &&... args)
Definition: rpc/Client.h:20
::rpc::client _client
Definition: rpc/Client.h:43
static Metadata MakeAsync()
Definition: Metadata.h:24