|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
10 #ifndef YARP_OS_IMPL_PORTCORE_H
11 #define YARP_OS_IMPL_PORTCORE_H
28 #ifndef YARP_NO_DEPRECATED // since YARP 3.3
29 #define YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE
31 #undef YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE
35 #include <condition_variable>
45 #define PORTCORE_SEND_NORMAL (1)
46 #define PORTCORE_SEND_LOG (2)
49 #define PORTCORE_IS_NULL (0)
50 #define PORTCORE_IS_RPC (1)
51 #define PORTCORE_IS_INPUT (2)
52 #define PORTCORE_IS_OUTPUT (4)
116 outputModifier(nullptr),
117 inputModifier(nullptr)
123 releaseOutModifier();
129 if (outputModifier !=
nullptr) {
130 outputModifier->close();
131 delete outputModifier;
132 outputModifier =
nullptr;
138 if (inputModifier !=
nullptr) {
139 inputModifier->close();
140 delete inputModifier;
141 inputModifier =
nullptr;
176 bool addOutput(
const std::string& dest,
179 bool onlyIfNeeded =
false);
192 void removeInput(
const std::string& src,
202 void removeOutput(
const std::string& dest,
212 bool removeIO(
const Route& route,
bool synch =
false);
250 void setName(
const std::string& name);
255 std::string getName();
262 void setEnvelope(
const std::string& envelope);
269 std::string getEnvelope();
298 this->m_flags = flags;
303 this->m_contactable = contactable;
317 bool listen(
const Contact& address,
bool shouldAnnounce =
true);
332 int getOutputCount();
355 this->m_waitBeforeSend = waitBeforeSend;
364 this->m_waitAfterSend = waitAfterSend;
380 bool start()
override;
385 bool manualStart(
const char* sourceName);
411 void close()
override;
426 const Contact& getAddress()
const;
428 void resetPortName(
const std::string& str);
438 void notifyCompletion(
void* tracker);
444 void setControlRegistration(
bool flag);
464 void resetReportCallback();
470 bool isListening()
const;
476 bool isManual()
const;
481 bool isInterrupted()
const;
483 void setTimeout(
float timeout);
488 Property* acquireProperties(
bool readOnly);
493 void releaseProperties(
Property* prop);
495 #ifndef YARP_NO_DEPRECATED // since YARP 3.3
501 #endif // YARP_NO_DEPRECATED
503 bool setCallbackLock(std::mutex* mutex =
nullptr);
505 bool removeCallbackLock();
509 bool tryLockCallback();
511 void unlockCallback();
519 void promiseType(
const Type& typ);
523 std::vector<PortCoreUnit *> m_units;
524 std::mutex m_stateMutex;
525 std::condition_variable m_stateCv;
526 std::mutex m_packetMutex;
527 std::condition_variable m_connectionChangeCv;
528 Face* m_face {
nullptr};
535 std::atomic<bool> m_listening {
false};
536 std::atomic<bool> m_running {
false};
537 std::atomic<bool> m_starting {
false};
538 std::atomic<bool> m_closing {
false};
539 std::atomic<bool> m_finished {
false};
540 bool m_finishing {
false};
541 bool m_waitBeforeSend {
true};
542 bool m_waitAfterSend {
true};
543 bool m_controlRegistration {
true};
544 bool m_interruptable {
true};
545 bool m_interrupted {
false};
546 bool m_manual {
false};
548 int m_connectionListeners {0};
549 int m_inputCount {0};
550 int m_outputCount {0};
551 int m_dataOutputCount {0};
553 bool m_logNeeded {
false};
554 PortCorePackets m_packets {};
555 std::string m_envelope;
556 float m_timeout {-1};
560 std::mutex* m_mutex {
nullptr};
561 #ifndef YARP_NO_DEPRECATED // since YARP 3.3
566 #endif // YARP_NO_DEPRECATED
567 bool m_mutexOwned {
false};
568 BufferedConnectionWriter m_envelopeWriter {
true};
570 std::mutex m_typeMutex;
571 bool m_checkedType {
false};
578 bool setTypeOfService(PortCoreUnit* unit,
int tos);
581 int getTypeOfService(PortCoreUnit* unit);
585 bool setProcessSchedulingParam(
int priority = -1,
int policy = -1);
591 bool detachPortMonitor(
bool isOutput);
594 bool setParamPortMonitor(
const yarp::os::Property& param,
bool isOutput, std::string& errMsg);
597 bool getParamPortMonitor(
yarp::os::Property& param,
bool isOutput, std::string& errMsg);
601 bool isUnit(
const Route& route,
int index);
607 void cleanUnits(
bool blocking =
true);
613 void addInput(InputProtocol* ip);
615 bool removeUnit(
const Route& route,
bool synch =
false,
bool* except =
nullptr);
624 #endif // YARP_OS_IMPL_PORTCORE_H
#define YARP_WARNING_PUSH
Starts a temporary alteration of the enabled warnings.
void setContactable(Contactable *contactable)
This manages a single threaded resource related to a single input or output connection.
bool read(yarp::os::ConnectionReader &reader) override
Callback for data.
A base class for connection types (tcp, mcast, shmem, ...) which are called carriers in YARP.
The output side of an active connection between two ports.
#define PORTCORE_IS_INPUT
yarp::os::Carrier * outputModifier
This is the heart of a yarp port.
Simple specification of the minimum functions needed from output streams.
unsigned int getFlags()
Check current configuration of port.
#define YARP_DEPRECATED
Expands to either the standard [[deprecated]] attribute or a compiler-specific decorator such as __at...
void setWaitBeforeSend(bool waitBeforeSend)
Upon being asked to send a message, should we wait for any existing message to be sent to all destina...
void releaseOutModifier()
A base class for objects that want information about port status changes.
Information about a connection between two ports.
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Information about a port connection or event.
void setWaitAfterSend(bool waitAfterSend)
After sending a message, should we wait for it to be sent to all destinations before returning?
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
virtual ~PortDataModifier()
yarp::os::Carrier * inputModifier
void setFlags(unsigned int flags)
Configure the port to meet certain restrictions in behavior.
#define YARP_WARNING_POP
Ends a temporary alteration of the enabled warnings.
An interface for reading from a network connection.
An abstraction for a thread of execution.
#define PORTCORE_IS_OUTPUT
The main, catch-all namespace for YARP.
Basic wrapper for mutual exclusion.
#define YARP_DISABLE_DEPRECATED_WARNING
Disable deprecated warnings in the following code.
The initial point-of-contact with a port.
A class for storing options and configuration information.