10 #ifndef YARP_OS_IMPL_PORTCORE_H
11 #define YARP_OS_IMPL_PORTCORE_H
29 #ifndef YARP_NO_DEPRECATED
30 #define YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE
32 #undef YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE
44 #define PORTCORE_SEND_NORMAL (1)
45 #define PORTCORE_SEND_LOG (2)
48 #define PORTCORE_IS_NULL (0)
49 #define PORTCORE_IS_RPC (1)
50 #define PORTCORE_IS_INPUT (2)
51 #define PORTCORE_IS_OUTPUT (4)
115 outputModifier(nullptr),
116 inputModifier(nullptr)
122 releaseOutModifier();
128 if (outputModifier !=
nullptr) {
129 outputModifier->close();
130 delete outputModifier;
131 outputModifier =
nullptr;
137 if (inputModifier !=
nullptr) {
138 inputModifier->close();
139 delete inputModifier;
140 inputModifier =
nullptr;
175 bool addOutput(
const std::string& dest,
178 bool onlyIfNeeded =
false);
191 void removeInput(
const std::string& src,
201 void removeOutput(
const std::string& dest,
211 bool removeIO(
const Route& route,
bool synch =
false);
249 void setName(
const std::string& name);
254 std::string getName();
261 void setEnvelope(
const std::string& envelope);
268 std::string getEnvelope();
297 this->m_flags = flags;
302 this->m_contactable = contactable;
316 bool listen(
const Contact& address,
bool shouldAnnounce =
true);
331 int getOutputCount();
354 this->m_waitBeforeSend = waitBeforeSend;
363 this->m_waitAfterSend = waitAfterSend;
379 bool start()
override;
384 bool manualStart(
const char* sourceName);
410 void close()
override;
425 const Contact& getAddress()
const;
427 void resetPortName(
const std::string& str);
437 void notifyCompletion(
void* tracker);
443 void setControlRegistration(
bool flag);
463 void resetReportCallback();
469 bool isListening()
const;
475 bool isManual()
const;
480 bool isInterrupted()
const;
482 void setTimeout(
float timeout);
484 Property* acquireProperties(
bool readOnly);
485 void releaseProperties(
Property* prop);
487 #ifndef YARP_NO_DEPRECATED
495 bool setCallbackLock(std::mutex* mutex =
nullptr);
497 bool removeCallbackLock();
501 bool tryLockCallback();
503 void unlockCallback();
511 void promiseType(
const Type& typ);
515 std::vector<PortCoreUnit *> m_units;
517 std::mutex m_packetMutex;
519 Face* m_face {
nullptr};
526 bool m_listening {
false};
527 bool m_running {
false};
528 bool m_starting {
false};
529 bool m_closing {
false};
530 bool m_finished {
false};
531 bool m_finishing {
false};
532 bool m_waitBeforeSend {
true};
533 bool m_waitAfterSend {
true};
534 bool m_controlRegistration {
true};
535 bool m_interruptable {
true};
536 bool m_interrupted {
false};
537 bool m_manual {
false};
539 int m_connectionListeners {0};
540 int m_inputCount {0};
541 int m_outputCount {0};
542 int m_dataOutputCount {0};
544 bool m_logNeeded {
false};
545 PortCorePackets m_packets {};
546 std::string m_envelope;
547 float m_timeout {-1};
551 std::mutex* m_mutex {
nullptr};
552 #ifndef YARP_NO_DEPRECATED
558 bool m_mutexOwned {
false};
559 BufferedConnectionWriter m_envelopeWriter {
true};
561 std::mutex m_typeMutex;
562 bool m_checkedType {
false};
569 bool setTypeOfService(PortCoreUnit* unit,
int tos);
572 int getTypeOfService(PortCoreUnit* unit);
576 bool setProcessSchedulingParam(
int priority = -1,
int policy = -1);
582 bool detachPortMonitor(
bool isOutput);
585 bool setParamPortMonitor(
const yarp::os::Property& param,
bool isOutput, std::string& errMsg);
588 bool getParamPortMonitor(
yarp::os::Property& param,
bool isOutput, std::string& errMsg);
592 bool isUnit(
const Route& route,
int index);
598 void cleanUnits(
bool blocking =
true);
604 void addInput(InputProtocol* ip);
606 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.
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.
A class for thread synchronization and mutual exclusion.
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.