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>
40#define PORTCORE_SEND_NORMAL (1)
41#define PORTCORE_SEND_LOG (2)
44#define PORTCORE_IS_NULL (0)
45#define PORTCORE_IS_RPC (1)
46#define PORTCORE_IS_INPUT (2)
47#define PORTCORE_IS_OUTPUT (4)
111 outputModifier(nullptr),
112 inputModifier(nullptr)
118 releaseOutModifier();
124 if (outputModifier !=
nullptr) {
125 outputModifier->close();
126 delete outputModifier;
127 outputModifier =
nullptr;
133 if (inputModifier !=
nullptr) {
134 inputModifier->close();
135 delete inputModifier;
136 inputModifier =
nullptr;
171 bool addOutput(
const std::string& dest,
174 bool onlyIfNeeded =
false);
187 void removeInput(
const std::string& src,
197 void removeOutput(
const std::string& dest,
207 bool removeIO(
const Route& route,
bool synch =
false);
245 void setName(
const std::string& name);
250 std::string getName();
257 void setEnvelope(
const std::string& envelope);
264 std::string getEnvelope();
293 this->m_flags = flags;
298 this->m_contactable = contactable;
312 bool listen(
const Contact& address,
bool shouldAnnounce =
true);
327 int getOutputCount();
350 this->m_waitBeforeSend = waitBeforeSend;
359 this->m_waitAfterSend = waitAfterSend;
375 bool start()
override;
380 bool manualStart(
const char* sourceName);
406 void close()
override;
421 const Contact& getAddress()
const;
423 void resetPortName(
const std::string& str);
433 void notifyCompletion(
void* tracker);
439 void setControlRegistration(
bool flag);
459 void resetReportCallback();
465 bool isListening()
const;
471 bool isManual()
const;
476 bool isInterrupted()
const;
478 void setTimeout(
float timeout);
483 Property* acquireProperties(
bool readOnly);
488 void releaseProperties(
Property* prop);
490#ifndef YARP_NO_DEPRECATED
498 bool setCallbackLock(std::mutex* mutex =
nullptr);
500 bool removeCallbackLock();
504 bool tryLockCallback();
506 void unlockCallback();
514 void promiseType(
const Type& typ);
518 std::vector<PortCoreUnit *> m_units;
519 std::mutex m_stateMutex;
520 std::condition_variable m_stateCv;
521 std::mutex m_packetMutex;
522 std::condition_variable m_connectionChangeCv;
523 Face* m_face {
nullptr};
530 std::atomic<bool> m_listening {
false};
531 std::atomic<bool> m_running {
false};
532 std::atomic<bool> m_starting {
false};
533 std::atomic<bool> m_closing {
false};
534 std::atomic<bool> m_finished {
false};
535 bool m_finishing {
false};
536 bool m_waitBeforeSend {
true};
537 bool m_waitAfterSend {
true};
538 bool m_controlRegistration {
true};
539 bool m_interruptable {
true};
540 bool m_interrupted {
false};
541 bool m_manual {
false};
543 int m_connectionListeners {0};
544 int m_inputCount {0};
545 int m_outputCount {0};
546 int m_dataOutputCount {0};
548 bool m_logNeeded {
false};
549 PortCorePackets m_packets {};
550 std::string m_envelope;
551 float m_timeout {-1};
555 std::mutex* m_mutex {
nullptr};
556#ifndef YARP_NO_DEPRECATED
562 bool m_mutexOwned {
false};
563 BufferedConnectionWriter m_envelopeWriter {
true};
565 std::mutex m_typeMutex;
566 bool m_checkedType {
false};
573 bool setTypeOfService(PortCoreUnit* unit,
int tos);
576 int getTypeOfService(PortCoreUnit* unit);
580 bool setProcessSchedulingParam(
int priority = -1,
int policy = -1);
586 bool detachPortMonitor(
bool isOutput);
589 bool setParamPortMonitor(
const yarp::os::Property& param,
bool isOutput, std::string& errMsg);
592 bool getParamPortMonitor(
yarp::os::Property& param,
bool isOutput, std::string& errMsg);
596 bool isUnit(
const Route& route,
int index);
602 void cleanUnits(
bool blocking =
true);
608 void addInput(InputProtocol* ip);
610 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 components from which ports and connections are built.
#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.