This is Unofficial EPICS BASE Doxygen Site
remote.h
Go to the documentation of this file.
1 
7 #ifndef REMOTE_H_
8 #define REMOTE_H_
9 
10 #ifdef epicsExportSharedSymbols
11 # define remoteEpicsExportSharedSymbols
12 # undef epicsExportSharedSymbols
13 #endif
14 
15 #include <map>
16 #include <string>
17 
18 #include <osiSock.h>
19 
20 #include <pv/serialize.h>
21 #include <pv/pvType.h>
22 #include <pv/byteBuffer.h>
23 #include <pv/timer.h>
24 #include <pv/pvData.h>
25 #include <pv/sharedPtr.h>
26 
27 #ifdef remoteEpicsExportSharedSymbols
28 # define epicsExportSharedSymbols
29 # undef remoteEpicsExportSharedSymbols
30 #endif
31 
32 #include <pv/pvaConstants.h>
33 #include <pv/configuration.h>
34 #include <pv/fairQueue.h>
35 #include <pv/pvaDefs.h>
36 
38 #include <pv/pvAccess.h>
39 
40 namespace epics {
41 namespace pvAccess {
42 
43 class TransportRegistry;
44 class ClientChannelImpl;
45 
46 enum QoS {
50  QOS_DEFAULT = 0x00,
62  QOS_PROCESS = 0x04,
66  QOS_INIT = 0x08,
70  QOS_DESTROY = 0x10,
74  QOS_SHARE = 0x20,
78  QOS_GET = 0x40,
82  QOS_GET_PUT = 0x80
83 };
84 
88  CMD_ECHO = 2,
96  CMD_GET = 10,
97  CMD_PUT = 11,
100  CMD_ARRAY = 14,
106  CMD_RPC = 20,
109 };
110 
115 };
116 
121 public:
123 
125 
126  virtual void startMessage(epics::pvData::int8 command, std::size_t ensureCapacity, epics::pvData::int32 payloadSize = 0) = 0;
127  virtual void endMessage() = 0;
128 
129  virtual void flush(bool lastMessageCompleted) = 0;
130 
131  virtual void setRecipient(osiSockAddr const & sendTo) = 0;
132 };
133 
137 class TransportSender : public Lockable, public fair_queue<TransportSender>::entry {
138 public:
140 
141  TransportSender() :bytesTX(0u), bytesRX(0u) {}
142  virtual ~TransportSender() {}
143 
152  virtual void send(epics::pvData::ByteBuffer* buffer, TransportSendControl* control) = 0;
153 
154  size_t bytesTX;
155  size_t bytesRX;
156 };
157 
158 class ClientChannelImpl;
159 class SecuritySession;
160 
165 public:
167 
168  static size_t num_instances;
169 
170  Transport();
171  virtual ~Transport();
172 
178  virtual bool acquire(std::tr1::shared_ptr<ClientChannelImpl> const & client) = 0;
179 
184  virtual void release(pvAccessID clientId) = 0;
185 
190  virtual std::string getType() const = 0;
191 
192  virtual const osiSockAddr& getRemoteAddress() const = 0;
193 
194  virtual const std::string& getRemoteName() const = 0;
195 
196  // TODO getContext?
197 
202  virtual std::size_t getReceiveBufferSize() const = 0;
203 
208  virtual epics::pvData::int16 getPriority() const = 0;
209 
214  virtual void setRemoteTransportReceiveBufferSize(std::size_t receiveBufferSize) = 0;
215 
220  virtual void setRemoteTransportSocketReceiveBufferSize(std::size_t socketReceiveBufferSize) = 0;
221 
226  // TODO enum
227  virtual void setByteOrder(int byteOrder) = 0;
228 
233  virtual void enqueueSendRequest(TransportSender::shared_pointer const & sender) = 0;
234 
238  virtual void flushSendQueue() = 0;
239 
244  virtual void verified(epics::pvData::Status const & status) = 0;
245 
250  virtual bool verify(epics::pvData::int32 timeoutMs) = 0;
251 
255  virtual void close() = 0;
256 
258  virtual void waitJoin() {}
259 
264  virtual bool isClosed() = 0;
265 
270  virtual void authNZMessage(epics::pvData::PVStructure::shared_pointer const & data) = 0;
271 
274 };
275 
276 class Channel;
277 class SecurityPlugin;
279 
283 class Context {
284 public:
286 
287  virtual ~Context() {}
288 
289  virtual epics::pvData::Timer::shared_pointer getTimer() = 0;
290 
291  virtual TransportRegistry* getTransportRegistry() = 0;
292 
293 
294 
295 
296  virtual Configuration::const_shared_pointer getConfiguration() = 0;
297 
301 
302  virtual void newServerDetected() = 0;
303 
304  virtual std::tr1::shared_ptr<Channel> getChannel(pvAccessID id) = 0;
305  virtual Transport::shared_pointer getSearchTransport() = 0;
306 };
307 
312 public:
314 
315  static size_t num_instances;
316 
317  ResponseHandler(Context* context, const std::string& description);
318  virtual ~ResponseHandler();
319 
330  virtual void
331  handleResponse(osiSockAddr* responseFrom, Transport::shared_pointer const & transport,
332  epics::pvData::int8 version, epics::pvData::int8 command, std::size_t payloadSize,
333  epics::pvData::ByteBuffer* payloadBuffer);
334 
335 protected:
339  std::string _description;
340 
345 };
346 
352 public:
354 
355  virtual ~ResponseRequest() {}
356 
361  virtual pvAccessID getIOID() const = 0;
362 
366  virtual void timeout() = 0;
367 
371  virtual void cancel() = 0;
372 
377  virtual void reportStatus(Channel::ConnectionState status) = 0;
378 
384  virtual std::tr1::shared_ptr<ChannelBaseRequester> getRequester() = 0;
385 
392  virtual void response(Transport::shared_pointer const & transport, epics::pvData::int8 version, epics::pvData::ByteBuffer* payloadBuffer) = 0;
393 
394 };
395 
396 
397 }
398 }
399 
400 #endif /* REMOTE_H_ */
int8_t int8
Definition: pvType.h:75
double timeout
Definition: pvutils.cpp:25
virtual void setRecipient(osiSockAddr const &sendTo)=0
epicsInt32 pvAccessID
Definition: pvaDefs.h:18
pvd::Status status
#define verify(exp)
Definition: acctst.c:65
epics::pvData::int32 _debugLevel
Definition: remote.h:344
virtual void waitJoin()
Call after close() to wait for any worker threads to exit.
Definition: remote.h:258
TODO only here because of the Lockable.
Definition: ntaggregate.cpp:16
Callback class for deserialization.
Definition: serialize.h:89
virtual void flush(bool lastMessageCompleted)=0
Definition: server.h:76
POINTER_DEFINITIONS(TransportSendControl)
#define epicsShareClass
Definition: shareLib.h:206
This class implements a Bytebuffer that is like the java.nio.ByteBuffer.
Definition: byteBuffer.h:233
Callback class for serialization.
Definition: serialize.h:34
int16_t int16
Definition: pvType.h:79
static size_t num_instances
Definition: remote.h:168
virtual void startMessage(epics::pvData::int8 command, std::size_t ensureCapacity, epics::pvData::int32 payloadSize=0)=0
int32_t int32
Definition: pvType.h:83