YARP
Yet Another Robot Platform
port_power/TargetVer2.h

Part of a series of examples on the different ways of using ports. See Port power tutorial.

/*
* SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
* SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef TARGETVER2_INC
#define TARGETVER2_INC
class Target : public yarp::os::Portable {
public:
int x;
int y;
bool write(yarp::os::ConnectionWriter& connection) const override {
connection.appendInt32(x);
connection.appendInt32(y);
return true;
}
bool read(yarp::os::ConnectionReader& connection) override {
x = connection.expectInt32();
y = connection.expectInt32();
return true;
}
};
#endif
An interface for reading from a network connection.
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
An interface for writing to a network connection.
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
This is a base class for objects that can be both read from and be written to the YARP network.
Definition: Portable.h:26
bool read(ConnectionReader &reader) override=0
Read this object from a network connection.
bool write(ConnectionWriter &writer) const override=0
Write this object to a network connection.