WPILibC++  unspecified
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 
21 class RpcCall final {
22  public:
26  RpcCall() : m_entry(0), m_call(0) {}
27 
33  RpcCall(NT_Entry entry, NT_RpcCall call) : m_entry(entry), m_call(call) {}
34 
35  RpcCall(RpcCall&& other);
36  RpcCall(const RpcCall&) = delete;
37  RpcCall& operator=(const RpcCall&) = delete;
38 
42  ~RpcCall();
43 
48  explicit operator bool() const { return m_call != 0; }
49 
55 
60  NT_RpcCall GetCall() const { return m_call; }
61 
68  bool GetResult(std::string* result);
69 
78  bool GetResult(std::string* result, double timeout, bool* timed_out);
79 
83  void CancelResult();
84 
85  friend void swap(RpcCall& first, RpcCall& second) {
86  using std::swap;
87  swap(first.m_entry, second.m_entry);
88  swap(first.m_call, second.m_call);
89  }
90 
91  private:
92  NT_Entry m_entry;
93  NT_RpcCall m_call;
94 };
95 
96 } // namespace nt
97 
98 #include "networktables/RpcCall.inl"
99 
100 #endif // NTCORE_NETWORKTABLES_RPCCALL_H_
RpcCall()
Construct invalid instance.
Definition: RpcCall.h:26
NetworkTables Remote Procedure Call.
Definition: RpcCall.h:21
bool GetResult(std::string *result)
Get the result (return value).
Definition: RpcCall.inl:24
NetworkTableEntry GetEntry() const
Get the RPC entry.
Definition: RpcCall.cpp:14
RpcCall(NT_Entry entry, NT_RpcCall call)
Construct from native handles.
Definition: RpcCall.h:33
Definition: IStorage.h:21
~RpcCall()
Destructor.
Definition: RpcCall.inl:19
void CancelResult()
Ignore the result.
Definition: RpcCall.inl:41
NetworkTables Entry.
Definition: NetworkTableEntry.h:35
NT_RpcCall GetCall() const
Get the call native handle.
Definition: RpcCall.h:60