YARP
Yet Another Robot Platform
Things.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #include <yarp/os/Things.h>
10 
11 #include <cstdio>
12 
13 using namespace yarp::os;
14 
16  beenRead(false),
17  conReader(nullptr),
18  writer(nullptr),
19  reader(nullptr),
20  portable(nullptr)
21 {
22 }
23 
25 {
26  delete portable;
27 }
28 
30 {
31  yarp::os::Things::writer = writer;
32 }
33 
35 {
36  return writer;
37 }
38 
40 {
41  yarp::os::Things::reader = reader;
42 }
43 
45 {
46  return reader;
47 }
48 
50 {
51  conReader = &reader;
52  delete portable;
53  portable = nullptr;
54  return true;
55 }
56 
58 {
59  if (writer != nullptr) {
60  return writer->write(connection);
61  }
62  if (portable != nullptr) {
63  return portable->write(connection);
64  }
65  return false;
66 }
67 
69 {
70  delete portable;
71  conReader = nullptr;
72  writer = nullptr;
73  reader = nullptr;
74  portable = nullptr;
75  beenRead = false;
76 }
77 
79 {
80  return beenRead;
81 }
yarp::os::Things::getPortWriter
yarp::os::PortWriter * getPortWriter()
Definition: Things.cpp:34
yarp::os::Things::hasBeenRead
bool hasBeenRead()
Definition: Things.cpp:78
Things.h
yarp::os::Things::setConnectionReader
bool setConnectionReader(yarp::os::ConnectionReader &reader)
set a reference to a ConnectionReader
Definition: Things.cpp:49
yarp::os::Things::reset
void reset()
Definition: Things.cpp:68
yarp::os::Things::write
bool write(yarp::os::ConnectionWriter &connection)
Definition: Things.cpp:57
yarp::os::PortWriter
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Definition: PortWriter.h:27
yarp::os::Portable::write
bool write(ConnectionWriter &writer) const override=0
Write this object to a network connection.
yarp::os::Things::~Things
virtual ~Things()
Definition: Things.cpp:24
yarp::os::Things::setPortWriter
void setPortWriter(yarp::os::PortWriter *writer)
Set the reference to a PortWriter object.
Definition: Things.cpp:29
yarp::os::PortReader
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:28
yarp::os::Things::Things
Things()
Definition: Things.cpp:15
yarp::os::ConnectionWriter
An interface for writing to a network connection.
Definition: ConnectionWriter.h:40
yarp::os::PortWriter::write
virtual bool write(ConnectionWriter &writer) const =0
Write this object to a network connection.
yarp::os::ConnectionReader
An interface for reading from a network connection.
Definition: ConnectionReader.h:40
yarp::os::Things::setPortReader
void setPortReader(yarp::os::PortReader *reader)
Set the reference to a PortReader object.
Definition: Things.cpp:39
yarp::os
An interface to the operating system, including Port based communication.
Definition: AbstractCarrier.h:17
yarp::os::Things::getPortReader
yarp::os::PortReader * getPortReader()
Definition: Things.cpp:44