pvAccessCPP  7.1.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rpcService.h
1 
7 #ifndef RPCSERVICE_H
8 #define RPCSERVICE_H
9 
10 #include <stdexcept>
11 
12 #ifdef epicsExportSharedSymbols
13 # define rpcServiceEpicsExportSharedSymbols
14 # undef epicsExportSharedSymbols
15 #endif
16 
17 #include <pv/sharedPtr.h>
18 #include <pv/status.h>
19 
20 #ifdef rpcServiceEpicsExportSharedSymbols
21 # define epicsExportSharedSymbols
22 # undef rpcServiceEpicsExportSharedSymbols
23 #endif
24 
25 #include <pv/pvAccess.h>
26 
27 #include <shareLib.h>
28 
29 namespace epics {
30 namespace pvAccess {
31 
32 class epicsShareClass RPCRequestException : public std::runtime_error {
33 public:
34 
35  explicit RPCRequestException(std::string const & message) :
36  std::runtime_error(message), m_status(epics::pvData::Status::STATUSTYPE_ERROR)
37  {}
38 
39  RPCRequestException(epics::pvData::Status::StatusType status, std::string const & message) :
40  std::runtime_error(message), m_status(status)
41  {}
42 
43  epics::pvData::Status::StatusType getStatus() const {
44  return m_status;
45  }
46 
47  epics::pvData::Status asStatus() const {
48  return epics::pvData::Status(m_status, what());
49  }
50 private:
51  epics::pvData::Status::StatusType m_status;
52 };
53 
54 class epicsShareClass RPCResponseCallback
55 {
56 public:
57  POINTER_DEFINITIONS(RPCResponseCallback);
58 
59  virtual ~RPCResponseCallback() {};
60 
61  virtual void requestDone(
62  epics::pvData::Status const & status,
63  epics::pvData::PVStructure::shared_pointer const & result
64  ) = 0;
65 };
66 
67 class epicsShareClass RPCServiceAsync
68 {
69 public:
70  POINTER_DEFINITIONS(RPCServiceAsync);
71 
72  virtual ~RPCServiceAsync() {};
73 
74  virtual void request(
75  epics::pvData::PVStructure::shared_pointer const & args,
76  RPCResponseCallback::shared_pointer const & callback
77  ) = 0;
78 };
79 
80 class epicsShareClass RPCService :
81  public RPCServiceAsync
82 {
83 public:
84  POINTER_DEFINITIONS(RPCService);
85 
86  virtual ~RPCService() {};
87 
88  virtual epics::pvData::PVStructure::shared_pointer request(
89  epics::pvData::PVStructure::shared_pointer const & args
90  ) = 0;
91 
92 private:
93  virtual void request(
94  epics::pvData::PVStructure::shared_pointer const & args,
95  RPCResponseCallback::shared_pointer const & callback
96  ) OVERRIDE FINAL;
97 };
98 
99 }
100 }
101 
102 #endif /* RPCSERVICE_H */
virtual const char * what() const _GLIBCXX_TXN_SAFE_DYN noexcept