YARP
Yet Another Robot Platform
BinPortable-inl.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_OS_BINPORTABLE_INL_H
11 #define YARP_OS_BINPORTABLE_INL_H
12 
15 
16 template <class T>
18 {
19  return t;
20 }
21 
22 template <class T>
23 
25 {
26  // An exception will get thrown upon error.
27  // Pending: translate this in expectBlock to a return value.
28  connection.convertTextMode(); // if connection is text-mode, convert!
29  connection.expectBlock((char*)(&t), sizeof(T));
30  return true;
31 }
32 
33 template <class T>
35 {
36  connection.appendBlock((char*)(&t), sizeof(T));
37  connection.convertTextMode(); // if connection is text-mode, convert!
38  return true;
39 }
40 
41 #endif // YARP_OS_BINPORTABLE_INL_H
yarp::os::ConnectionWriter::appendBlock
virtual void appendBlock(const char *data, size_t len)=0
Send a block of data to the network connection.
t
float t
Definition: FfmpegWriter.cpp:74
ConnectionWriter.h
yarp::os::BinPortable::content
T & content()
Get the internal structure that will be read or written.
Definition: BinPortable-inl.h:17
yarp::os::BinPortable::read
bool read(ConnectionReader &connection) override
Read this object from a network connection.
Definition: BinPortable-inl.h:24
yarp::os::ConnectionWriter
An interface for writing to a network connection.
Definition: ConnectionWriter.h:40
yarp::os::ConnectionReader::convertTextMode
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary.
yarp::os::ConnectionWriter::convertTextMode
virtual bool convertTextMode()=0
Converts a standard description in binary into a textual description, if the connection is in text-mo...
yarp::os::ConnectionReader
An interface for reading from a network connection.
Definition: ConnectionReader.h:40
yarp::os::BinPortable::write
bool write(ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: BinPortable-inl.h:34
yarp::os::ConnectionReader::expectBlock
virtual bool expectBlock(char *data, size_t len)=0
Read a block of data from the network connection.
ConnectionReader.h