YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
PortablePair.h
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#ifndef YARP_OS_PORTABLEPAIR_H
8#define YARP_OS_PORTABLEPAIR_H
9
10#include <yarp/os/Bottle.h>
11#include <yarp/os/Portable.h>
12
13namespace yarp::os {
14
16{
17public:
25 static bool readPair(ConnectionReader& connection,
26 Portable& head,
27 Portable& body);
28
36 static bool writePair(ConnectionWriter& connection,
37 const Portable& head,
38 const Portable& body);
39};
40
45template <class HEAD, class BODY>
47{
48public:
53
58
65 {
66 return readPair(connection, head, body);
67 }
68
74 bool write(ConnectionWriter& connection) const override
75 {
76 return writePair(connection, head, body);
77 }
78
83 void onCompletion() const override
84 {
85 head.onCompletion();
86 body.onCompletion();
87 }
88};
89
90} // namespace yarp::os
91
92#endif // YARP_OS_PORTABLEPAIR_H
A mini-server for performing network communication in the background.
An interface for reading from a network connection.
An interface for writing to a network connection.
static bool writePair(ConnectionWriter &connection, const Portable &head, const Portable &body)
Writes an object pair to a network connection.
static bool readPair(ConnectionReader &connection, Portable &head, Portable &body)
Reads an object pair from a network connection.
Group a pair of objects to be sent and received together.
BODY body
An object of the second type (BODY).
bool write(ConnectionWriter &connection) const override
Writes this object pair to a network connection.
HEAD head
An object of the first type (HEAD).
bool read(ConnectionReader &connection) override
Reads this object pair from a network connection.
void onCompletion() const override
This is called when the port has finished all writing operations.
This is a base class for objects that can be both read from and be written to the YARP network.
Definition Portable.h:25
An interface to the operating system, including Port based communication.
#define YARP_os_API
Definition api.h:18