YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
PortCoreAdapter.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_PORTCOREADAPTER_H
8#define YARP_OS_IMPL_PORTCOREADAPTER_H
9
10#include <yarp/os/Port.h>
11#include <yarp/os/Semaphore.h>
13#include <mutex>
14
15namespace yarp::os::impl {
16
18 public PortCore
19{
20private:
21 std::mutex stateMutex;
22 PortReader* readDelegate { nullptr };
23 PortReader* permanentReadDelegate { nullptr };
24 PortReader* adminReadDelegate { nullptr };
25 PortWriter* writeDelegate { nullptr };
26 //PortReaderCreator *readCreatorDelegate { nullptr };
27 bool readResult { false };
28 bool readActive { false };
29 bool readBackground { false };
30 bool willReply { false };
31 bool closed { false };
32 bool opened { false };
33 bool replyDue { false };
34 bool dropDue { false };
35 yarp::os::Semaphore produce { 0 };
36 yarp::os::Semaphore consume { 0 };
37 yarp::os::Semaphore readBlock { 1 };
38 PortReaderCreator* recReadCreator { nullptr };
39 int recWaitAfterSend { -1 };
40 bool usedForRead { false };
41 bool usedForWrite { false };
42 bool usedForRpc { false };
43
44public:
45 bool includeNode { false };
46 bool commitToRead { false };
47 bool commitToWrite { false };
48 bool commitToRpc { false };
49 bool active { false };
50 std::mutex* recCallbackLock { nullptr };
51 bool haveCallbackLock { false };
52
53 PortCoreAdapter(Port& owner);
54 void openable();
55 void alertOnRead();
56 void alertOnWrite();
57 void alertOnRpc();
58 void setReadOnly();
59 void setWriteOnly();
60 void setRpc();
61 void finishReading();
62 void finishWriting();
63 void resumeFull();
64 bool read(ConnectionReader& reader) override;
65 bool read(PortReader& reader, bool willReply = false);
66 bool reply(PortWriter& writer, bool drop, bool interrupted);
67 void configReader(PortReader& reader);
68 void configAdminReader(PortReader& reader);
71 bool configCallbackLock(std::mutex* lock);
77 bool isOpened();
78 void setOpen(bool opened);
79 void includeNodeInName(bool flag);
80};
81
82} // namespace yarp::os::impl
83
84#endif // YARP_OS_IMPL_PORTCOREADAPTER_H
A mini-server for performing network communication in the background.
An interface for reading from a network connection.
A creator for readers.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition PortReader.h:24
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Definition PortWriter.h:23
A mini-server for network communication.
Definition Port.h:46
A class for thread synchronization and mutual exclusion.
Definition Semaphore.h:25
PortReaderCreator * checkReadCreator()
void configWaitAfterSend(bool waitAfterSend)
void configReadCreator(PortReaderCreator &creator)
void configAdminReader(PortReader &reader)
bool configCallbackLock(std::mutex *lock)
bool reply(PortWriter &writer, bool drop, bool interrupted)
void configReader(PortReader &reader)
bool read(ConnectionReader &reader) override
Callback for data.
The components from which ports and connections are built.