YARP
Yet Another Robot Platform
PortCoreInputUnit.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_IMPL_PORTCOREINPUTUNIT_H
8 #define YARP_OS_IMPL_PORTCOREINPUTUNIT_H
9 
10 #include <yarp/os/InputProtocol.h>
11 #include <yarp/os/Semaphore.h>
12 #include <yarp/os/impl/PortCore.h>
14 
15 namespace yarp {
16 namespace os {
17 namespace impl {
18 
24  public PortCoreUnit
25 {
26 public:
38  int index,
39  InputProtocol* ip,
40  bool reversed);
41 
45  virtual ~PortCoreInputUnit();
46 
52  bool start() override;
53 
61  void run() override;
62 
63  bool isInput() override;
64 
65  void close() override;
66 
67  bool isFinished() override;
68 
69  const std::string& getName();
70 
71  Route getRoute() override;
72 
73  bool interrupt() override;
74 
75  void setCarrierParams(const yarp::os::Property& params) override;
76 
77  void getCarrierParams(yarp::os::Property& params) override;
78 
79  // return the protocol object
81 
82  bool isBusy() override;
83 
84 private:
85  InputProtocol* ip;
86  yarp::os::Semaphore phase, access;
87  bool closing, finished, running;
88  std::string name;
89  yarp::os::PortReader* localReader;
90  Route officialRoute;
91  bool reversed;
92 
93  void closeMain();
94 
95  bool skipIncomingData(yarp::os::ConnectionReader& reader);
96 
97  static void envelopeReadCallback(void* data, const Bytes& envelope);
98 };
99 
100 } // namespace impl
101 } // namespace os
102 } // namespace yarp
103 
104 #endif // YARP_OS_IMPL_PORTCOREINPUTUNIT_H
A simple abstraction for a block of bytes.
Definition: Bytes.h:25
An interface for reading from a network connection.
The input side of an active connection between two ports.
Definition: InputProtocol.h:35
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:25
A class for storing options and configuration information.
Definition: Property.h:34
Information about a connection between two ports.
Definition: Route.h:29
A class for thread synchronization and mutual exclusion.
Definition: Semaphore.h:26
Manager for a single input to a port.
PortCoreInputUnit(PortCore &owner, int index, InputProtocol *ip, bool reversed)
Constructor.
void run() override
The body of the thread associated with this input.
bool start() override
Start a thread running to serve this input.
void getCarrierParams(yarp::os::Property &params) override
void setCarrierParams(const yarp::os::Property &params) override
Set arbitrary parameters for this connection.
bool interrupt() override
Interrupt the connection.
This manages a single threaded resource related to a single input or output connection.
Definition: PortCoreUnit.h:27
The main, catch-all namespace for YARP.
Definition: dirs.h:16