7 #ifndef YARP_OS_IMPL_PORTCORE_H
8 #define YARP_OS_IMPL_PORTCORE_H
25 #ifndef YARP_NO_DEPRECATED
26 #define YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE
28 #undef YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE
32 #include <condition_variable>
42 #define PORTCORE_SEND_NORMAL (1)
43 #define PORTCORE_SEND_LOG (2)
46 #define PORTCORE_IS_NULL (0)
47 #define PORTCORE_IS_RPC (1)
48 #define PORTCORE_IS_INPUT (2)
49 #define PORTCORE_IS_OUTPUT (4)
113 outputModifier(nullptr),
114 inputModifier(nullptr)
120 releaseOutModifier();
126 if (outputModifier !=
nullptr) {
127 outputModifier->close();
128 delete outputModifier;
129 outputModifier =
nullptr;
135 if (inputModifier !=
nullptr) {
136 inputModifier->close();
137 delete inputModifier;
138 inputModifier =
nullptr;
173 bool addOutput(
const std::string& dest,
176 bool onlyIfNeeded =
false);
189 void removeInput(
const std::string& src,
199 void removeOutput(
const std::string& dest,
209 bool removeIO(
const Route& route,
bool synch =
false);
247 void setName(
const std::string& name);
252 std::string getName();
259 void setEnvelope(
const std::string& envelope);
266 std::string getEnvelope();
295 this->m_flags = flags;
300 this->m_contactable = contactable;
314 bool listen(
const Contact& address,
bool shouldAnnounce =
true);
329 int getOutputCount();
352 this->m_waitBeforeSend = waitBeforeSend;
361 this->m_waitAfterSend = waitAfterSend;
377 bool start()
override;
382 bool manualStart(
const char* sourceName);
408 void close()
override;
423 const Contact& getAddress()
const;
425 void resetPortName(
const std::string& str);
435 void notifyCompletion(
void* tracker);
441 void setControlRegistration(
bool flag);
461 void resetReportCallback();
467 bool isListening()
const;
473 bool isManual()
const;
478 bool isInterrupted()
const;
480 void setTimeout(
float timeout);
485 Property* acquireProperties(
bool readOnly);
490 void releaseProperties(
Property* prop);
492 #ifndef YARP_NO_DEPRECATED
500 bool setCallbackLock(std::mutex* mutex =
nullptr);
502 bool removeCallbackLock();
506 bool tryLockCallback();
508 void unlockCallback();
516 void promiseType(
const Type& typ);
520 std::vector<PortCoreUnit *> m_units;
521 std::mutex m_stateMutex;
522 std::condition_variable m_stateCv;
523 std::mutex m_packetMutex;
524 std::condition_variable m_connectionChangeCv;
525 Face* m_face {
nullptr};
532 std::atomic<bool> m_listening {
false};
533 std::atomic<bool> m_running {
false};
534 std::atomic<bool> m_starting {
false};
535 std::atomic<bool> m_closing {
false};
536 std::atomic<bool> m_finished {
false};
537 bool m_finishing {
false};
538 bool m_waitBeforeSend {
true};
539 bool m_waitAfterSend {
true};
540 bool m_controlRegistration {
true};
541 bool m_interruptable {
true};
542 bool m_interrupted {
false};
543 bool m_manual {
false};
545 int m_connectionListeners {0};
546 int m_inputCount {0};
547 int m_outputCount {0};
548 int m_dataOutputCount {0};
550 bool m_logNeeded {
false};
551 PortCorePackets m_packets {};
552 std::string m_envelope;
553 float m_timeout {-1};
557 std::mutex* m_mutex {
nullptr};
558 #ifndef YARP_NO_DEPRECATED
564 bool m_mutexOwned {
false};
565 BufferedConnectionWriter m_envelopeWriter {
true};
567 std::mutex m_typeMutex;
568 bool m_checkedType {
false};
575 bool setTypeOfService(PortCoreUnit* unit,
int tos);
578 int getTypeOfService(PortCoreUnit* unit);
582 bool setProcessSchedulingParam(
int priority = -1,
int policy = -1);
588 bool detachPortMonitor(
bool isOutput);
591 bool setParamPortMonitor(
const yarp::os::Property& param,
bool isOutput, std::string& errMsg);
594 bool getParamPortMonitor(
yarp::os::Property& param,
bool isOutput, std::string& errMsg);
598 bool isUnit(
const Route& route,
int index);
604 void cleanUnits(
bool blocking =
true);
610 void addInput(InputProtocol* ip);
612 bool removeUnit(
const Route& route,
bool synch =
false,
bool* except =
nullptr);
#define PORTCORE_IS_INPUT
#define PORTCORE_IS_OUTPUT
A base class for connection types (tcp, mcast, shmem, ...) which are called carriers in YARP.
An interface for reading from a network connection.
The initial point-of-contact with a port.
Basic wrapper for mutual exclusion.
The output side of an active connection between two ports.
Simple specification of the minimum functions needed from output streams.
Information about a port connection or event.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
A base class for objects that want information about port status changes.
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
A class for storing options and configuration information.
Information about a connection between two ports.
This manages a single threaded resource related to a single input or output connection.
void setFlags(unsigned int flags)
Configure the port to meet certain restrictions in behavior.
void setWaitAfterSend(bool waitAfterSend)
After sending a message, should we wait for it to be sent to all destinations before returning?
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 setContactable(Contactable *contactable)
bool read(yarp::os::ConnectionReader &reader) override
Callback for data.
unsigned int getFlags()
Check current configuration of port.
This is the heart of a yarp port.
yarp::os::Carrier * outputModifier
yarp::os::Carrier * inputModifier
virtual ~PortDataModifier()
void releaseOutModifier()
An abstraction for a thread of execution.
#define YARP_DEPRECATED
Expands to either the standard [[deprecated]] attribute or a compiler-specific decorator such as __at...
The main, catch-all namespace for YARP.
#define YARP_WARNING_POP
Ends a temporary alteration of the enabled warnings.
#define YARP_WARNING_PUSH
Starts a temporary alteration of the enabled warnings.
#define YARP_DISABLE_DEPRECATED_WARNING
Disable deprecated warnings in the following code.