YARP
Yet Another Robot Platform
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
14#ifndef YARP_NO_DEPRECATED // Since YARP 3.3
15#define YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE
16#include <yarp/os/Mutex.h>
17#undef YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE
18#endif // YARP_NO_DEPRECATED
19
20#include <mutex>
21
22namespace yarp::os::impl {
23
25 public PortCore
26{
27private:
28 std::mutex stateMutex;
29 PortReader* readDelegate { nullptr };
30 PortReader* permanentReadDelegate { nullptr };
31 PortReader* adminReadDelegate { nullptr };
32 PortWriter* writeDelegate { nullptr };
33 //PortReaderCreator *readCreatorDelegate { nullptr };
34 bool readResult { false };
35 bool readActive { false };
36 bool readBackground { false };
37 bool willReply { false };
38 bool closed { false };
39 bool opened { false };
40 bool replyDue { false };
41 bool dropDue { false };
42 yarp::os::Semaphore produce { 0 };
43 yarp::os::Semaphore consume { 0 };
44 yarp::os::Semaphore readBlock { 1 };
45 PortReaderCreator* recReadCreator { nullptr };
46 int recWaitAfterSend { -1 };
47 bool usedForRead { false };
48 bool usedForWrite { false };
49 bool usedForRpc { false };
50
51public:
52 bool includeNode { false };
53 bool commitToRead { false };
54 bool commitToWrite { false };
55 bool commitToRpc { false };
56 bool active { false };
57 std::mutex* recCallbackLock { nullptr };
58#ifndef YARP_NO_DEPRECATED // Since YARP 3.3
63#endif
64 bool haveCallbackLock { false };
65
66 PortCoreAdapter(Port& owner);
67 void openable();
68 void alertOnRead();
69 void alertOnWrite();
70 void alertOnRpc();
71 void setReadOnly();
72 void setWriteOnly();
73 void setRpc();
74 void finishReading();
75 void finishWriting();
76 void resumeFull();
77 bool read(ConnectionReader& reader) override;
78 bool read(PortReader& reader, bool willReply = false);
79 bool reply(PortWriter& writer, bool drop, bool interrupted);
80 void configReader(PortReader& reader);
81 void configAdminReader(PortReader& reader);
83 void configWaitAfterSend(bool waitAfterSend);
84#ifndef YARP_NO_DEPRECATED // Since YARP 3.3
88 bool configCallbackLock(Mutex* lock);
90#endif
91 bool configCallbackLock(std::mutex* lock);
97 bool isOpened();
98 void setOpen(bool opened);
99 void includeNodeInName(bool flag);
100};
101
102} // namespace yarp::os::impl
103
104#endif // YARP_OS_IMPL_PORTCOREADAPTER_H
An interface for reading from a network connection.
Basic wrapper for mutual exclusion.
Definition: Mutex.h:31
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 reply(PortWriter &writer, bool drop, bool interrupted)
yarp::os::Mutex * old_recCallbackLock
void configReader(PortReader &reader)
bool read(ConnectionReader &reader) override
Callback for data.
#define YARP_DEPRECATED
Expands to either the standard [[deprecated]] attribute or a compiler-specific decorator such as __at...
Definition: compiler.h:2894
The components from which ports and connections are built.
#define YARP_WARNING_POP
Ends a temporary alteration of the enabled warnings.
Definition: system.h:334
#define YARP_WARNING_PUSH
Starts a temporary alteration of the enabled warnings.
Definition: system.h:333
#define YARP_DISABLE_DEPRECATED_WARNING
Disable deprecated warnings in the following code.
Definition: system.h:335