WPILibC++  2019.1.1-beta-4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
RpcCall.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #ifndef NTCORE_NETWORKTABLES_RPCCALL_H_
9 #define NTCORE_NETWORKTABLES_RPCCALL_H_
10 
11 #include <string>
12 #include <utility>
13 
14 #include "ntcore_c.h"
15 
16 namespace nt {
17 
18 class NetworkTableEntry;
19 
24 class RpcCall final {
25  public:
29  RpcCall() : m_entry(0), m_call(0) {}
30 
37  RpcCall(NT_Entry entry, NT_RpcCall call) : m_entry(entry), m_call(call) {}
38 
39  RpcCall(RpcCall&& other);
40  RpcCall(const RpcCall&) = delete;
41  RpcCall& operator=(const RpcCall&) = delete;
42 
46  ~RpcCall();
47 
53  explicit operator bool() const { return m_call != 0; }
54 
61 
67  NT_RpcCall GetCall() const { return m_call; }
68 
76  bool GetResult(std::string* result);
77 
87  bool GetResult(std::string* result, double timeout, bool* timed_out);
88 
92  void CancelResult();
93 
94  friend void swap(RpcCall& first, RpcCall& second) {
95  using std::swap;
96  swap(first.m_entry, second.m_entry);
97  swap(first.m_call, second.m_call);
98  }
99 
100  private:
101  NT_Entry m_entry;
102  NT_RpcCall m_call;
103 };
104 
105 } // namespace nt
106 
107 #include "networktables/RpcCall.inl"
108 
109 #endif // NTCORE_NETWORKTABLES_RPCCALL_H_
RpcCall()
Construct invalid instance.
Definition: RpcCall.h:29
NetworkTables Remote Procedure Call.
Definition: RpcCall.h:24
bool GetResult(std::string *result)
Get the result (return value).
Definition: RpcCall.inl:24
RpcCall(NT_Entry entry, NT_RpcCall call)
Construct from native handles.
Definition: RpcCall.h:37
NetworkTables (ntcore) namespace.
Definition: ITable.h:21
~RpcCall()
Destructor.
Definition: RpcCall.inl:19
void CancelResult()
Ignore the result.
Definition: RpcCall.inl:41
NetworkTables Entry.
Definition: NetworkTableEntry.h:38
NT_RpcCall GetCall() const
Get the call native handle.
Definition: RpcCall.h:67
NetworkTableEntry GetEntry() const
Get the RPC entry.