YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
XmlRpcStream.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef YARP_XMLRPC_CARRIER_XMLRPCSTREAM_H
7#define YARP_XMLRPC_CARRIER_XMLRPCSTREAM_H
8
14
15#include "XmlRpcClient.h"
16#include "XmlRpcServerConnection.h"
17
22{
23private:
24 TwoWayStream *delegate;
25 YarpXmlRpc::XmlRpcClient client;
26 YarpXmlRpc::XmlRpcServerConnection server;
29 bool sender;
30 bool firstRound;
31 bool interpretRos;
32public:
33 XmlRpcStream(TwoWayStream *delegate, bool sender, bool interpretRos) :
34 client("notset", 0),
35 server(0, nullptr),
36 sender(sender),
37 interpretRos(interpretRos)
38 {
39 this->delegate = delegate;
40 client.reset();
41 server.reset();
42 firstRound = true;
43 }
44
45 virtual ~XmlRpcStream()
46 {
47 if (delegate != nullptr) {
48 delete delegate;
49 delegate = nullptr;
50 }
51 }
52
54 {
55 return *this;
56 }
57
59 {
60 return *this;
61 }
62
63
64 const yarp::os::Contact& getLocalAddress() const override
65 {
66 return delegate->getLocalAddress();
67 }
68
69 const yarp::os::Contact& getRemoteAddress() const override
70 {
71 return delegate->getRemoteAddress();
72 }
73
74 bool isOk() const override
75 {
76 return delegate->isOk();
77 }
78
79 void reset() override
80 {
81 delegate->reset();
82 }
83
84 void close() override
85 {
86 delegate->close();
87 }
88
89 void beginPacket() override
90 {
91 delegate->beginPacket();
92 }
93
94 void endPacket() override
95 {
96 delegate->endPacket();
97 }
98
100 void write(const yarp::os::Bytes& b) override;
101
104
105 void interrupt() override
106 {
107 delegate->getInputStream().interrupt();
108 }
109
110};
111
112#endif // YARP_XMLRPC_CARRIER_XMLRPCSTREAM_H
const yarp::os::Contact & getLocalAddress() const override
Get the address of the local side of the stream.
yarp::os::OutputStream & getOutputStream() override
Get an OutputStream to write to.
void beginPacket() override
Mark the beginning of a logical packet.
virtual ~XmlRpcStream()
void endPacket() override
Mark the end of a logical packet (see beginPacket).
bool isOk() const override
Check if the stream is ok or in an error state.
void write(const yarp::os::Bytes &b) override
Write a block of bytes to the stream.
void interrupt() override
Interrupt the stream.
XmlRpcStream(TwoWayStream *delegate, bool sender, bool interpretRos)
void reset() override
Reset the stream.
const yarp::os::Contact & getRemoteAddress() const override
Get the address of the remote side of the stream.
void close() override
Terminate the stream.
yarp::os::InputStream & getInputStream() override
Get an InputStream to read from.
A simple abstraction for a block of bytes.
Definition Bytes.h:24
Represents how to reach a part of a YARP network.
Definition Contact.h:33
Simple specification of the minimum functions needed from input streams.
Definition InputStream.h:25
virtual int read()
Read and return a single byte.
Simple specification of the minimum functions needed from output streams.
virtual void write(char ch)
Write a single byte to the stream.
An InputStream that reads from a string.
An OutputStream that produces a string.
A stream which can be asked to perform bidirectional communication.
::ssize_t ssize_t
Definition numeric.h:86