YARP
Yet Another Robot Platform
PortCoreInputUnit.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_IMPL_PORTCOREINPUTUNIT_H
11 #define YARP_OS_IMPL_PORTCOREINPUTUNIT_H
12 
13 #include <yarp/os/InputProtocol.h>
14 #include <yarp/os/Semaphore.h>
15 #include <yarp/os/impl/PortCore.h>
17 
18 namespace yarp {
19 namespace os {
20 namespace impl {
21 
27  public PortCoreUnit
28 {
29 public:
41  int index,
42  InputProtocol* ip,
43  bool reversed);
44 
48  virtual ~PortCoreInputUnit();
49 
55  bool start() override;
56 
64  void run() override;
65 
66  bool isInput() override;
67 
68  void close() override;
69 
70  bool isFinished() override;
71 
72  const std::string& getName();
73 
74  Route getRoute() override;
75 
76  bool interrupt() override;
77 
78  void setCarrierParams(const yarp::os::Property& params) override;
79 
80  void getCarrierParams(yarp::os::Property& params) override;
81 
82  // return the protocol object
84 
85  bool isBusy() override;
86 
87 private:
88  InputProtocol* ip;
89  yarp::os::Semaphore phase, access;
90  bool closing, finished, running;
91  std::string name;
92  yarp::os::PortReader* localReader;
93  Route officialRoute;
94  bool reversed;
95 
96  void closeMain();
97 
98  bool skipIncomingData(yarp::os::ConnectionReader& reader);
99 
100  static void envelopeReadCallback(void* data, const Bytes& envelope);
101 };
102 
103 } // namespace impl
104 } // namespace os
105 } // namespace yarp
106 
107 #endif // YARP_OS_IMPL_PORTCOREINPUTUNIT_H
yarp::os::impl::PortCoreInputUnit::setCarrierParams
void setCarrierParams(const yarp::os::Property &params) override
Set arbitrary parameters for this connection.
Definition: PortCoreInputUnit.cpp:475
yarp::os::impl::PortCoreInputUnit::getCarrierParams
void getCarrierParams(yarp::os::Property &params) override
Definition: PortCoreInputUnit.cpp:482
yarp::os::impl::PortCoreInputUnit::interrupt
bool interrupt() override
Interrupt the connection.
Definition: PortCoreInputUnit.cpp:461
yarp::os::impl::PortCoreInputUnit::run
void run() override
The body of the thread associated with this input.
Definition: PortCoreInputUnit.cpp:85
PortCoreUnit.h
yarp::os::Semaphore
A class for thread synchronization and mutual exclusion.
Definition: Semaphore.h:29
yarp::os::impl::PortCoreUnit
This manages a single threaded resource related to a single input or output connection.
Definition: PortCoreUnit.h:30
yarp::os::impl::PortCoreInputUnit::PortCoreInputUnit
PortCoreInputUnit(PortCore &owner, int index, InputProtocol *ip, bool reversed)
Constructor.
Definition: PortCoreInputUnit.cpp:32
yarp::os::impl::PortCoreInputUnit::getName
const std::string & getName()
Definition: PortCoreInputUnit.cpp:456
yarp::os::impl::PortCoreInputUnit::~PortCoreInputUnit
virtual ~PortCoreInputUnit()
Destructor.
Definition: PortCoreInputUnit.cpp:55
yarp::os::impl::PortCoreInputUnit::close
void close() override
Definition: PortCoreInputUnit.cpp:446
InputProtocol.h
yarp::os::impl::PortCore
Definition: PortCore.h:155
yarp::os::Route
Information about a connection between two ports.
Definition: Route.h:32
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::impl::PortCoreInputUnit::isBusy
bool isBusy() override
Definition: PortCoreInputUnit.cpp:542
yarp::os::impl::PortCoreInputUnit::start
bool start() override
Start a thread running to serve this input.
Definition: PortCoreInputUnit.cpp:65
yarp::os::impl::PortCoreInputUnit::getInPutProtocol
InputProtocol * getInPutProtocol()
Definition: PortCoreInputUnit.cpp:490
yarp::os::impl::PortCoreInputUnit::isInput
bool isInput() override
Definition: PortCoreInputUnit.cpp:441
Semaphore.h
yarp::os::Bytes
A simple abstraction for a block of bytes.
Definition: Bytes.h:28
yarp::os::ConnectionReader
An interface for reading from a network connection.
Definition: ConnectionReader.h:40
yarp::os::impl::PortCoreInputUnit::isFinished
bool isFinished() override
Definition: PortCoreInputUnit.cpp:451
PortCore.h
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::os::impl::PortCoreInputUnit
Manager for a single input to a port.
Definition: PortCoreInputUnit.h:28
yarp::os::InputProtocol
The input side of an active connection between two ports.
Definition: InputProtocol.h:38
yarp::os::impl::PortCoreInputUnit::getRoute
Route getRoute() override
Definition: PortCoreInputUnit.cpp:520
yarp::os::Property
A class for storing options and configuration information.
Definition: Property.h:37