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
A simple abstraction for a block of bytes.
Definition: Bytes.h:28
An interface for reading from a network connection.
The input side of an active connection between two ports.
Definition: InputProtocol.h:38
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:28
A class for storing options and configuration information.
Definition: Property.h:37
Information about a connection between two ports.
Definition: Route.h:32
A class for thread synchronization and mutual exclusion.
Definition: Semaphore.h:29
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:30
The main, catch-all namespace for YARP.
Definition: environment.h:18