YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
RpcClient.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <yarp/os/RpcClient.h>
8
10
11using namespace yarp::os;
12using namespace yarp::os::impl;
13
14namespace {
15YARP_OS_LOG_COMPONENT(RPCCLIENT, "yarp.os.RpcClient")
16} // namespace
17
19{
20public:
21 // an RpcClient may be implemented with a regular port
23};
24
25
27 mPriv(new Private)
28{
29 mPriv->port.setInputMode(false);
30 mPriv->port.setOutputMode(true);
31 mPriv->port.setRpcMode(true);
32}
33
35{
36 mPriv->port.close();
37 delete mPriv;
38}
39
40bool RpcClient::read(PortReader& reader, bool willReply)
41{
42 YARP_UNUSED(reader);
43 YARP_UNUSED(willReply);
45 "cannot read from RpcClient %s, please use a regular Port for that",
46 mPriv->port.getName().c_str());
47 return false;
48}
49
51{
52 YARP_UNUSED(writer);
53 return false;
54}
55
57{
58 YARP_UNUSED(writer);
59 return false;
60}
61
66
71
76
78{
79 return mPriv->port;
80}
81
82const Port& RpcClient::asPort() const
83{
84 return mPriv->port;
85}
A mini-server for performing network communication in the background.
virtual std::string getName() const
Get name of port.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition PortReader.h:24
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Definition PortWriter.h:23
A mini-server for network communication.
Definition Port.h:46
RpcClient()
Constructor.
Definition RpcClient.cpp:26
void setInputMode(bool expectInput) override
Configure the port to allow or forbid inputs.
Definition RpcClient.cpp:62
void setOutputMode(bool expectOutput) override
Configure the port to allow or forbid outputs.
Definition RpcClient.cpp:67
bool reply(PortWriter &writer) override
Send an object as a reply to an object read from the port.
Definition RpcClient.cpp:50
bool replyAndDrop(PortWriter &writer) override
Same as reply(), but closes connection after reply.
Definition RpcClient.cpp:56
~RpcClient() override
Destructor.
Definition RpcClient.cpp:34
bool read(PortReader &reader, bool willReply=false) override
Read an object from the port.
Definition RpcClient.cpp:40
Port & asPort() override
Get the concrete Port being used for communication.
Definition RpcClient.cpp:77
void setRpcMode(bool expectRpc) override
Configure the port to be RPC only.
Definition RpcClient.cpp:72
#define yCError(component,...)
#define yCAssert(component, x)
#define YARP_OS_LOG_COMPONENT(name, name_string)
The components from which ports and connections are built.
An interface to the operating system, including Port based communication.
#define YARP_UNUSED(var)
Definition api.h:162