7#ifndef YARP_OS_IMPL_PORTCORE_H
8#define YARP_OS_IMPL_PORTCORE_H
26#include <condition_variable>
34#define PORTCORE_SEND_NORMAL (1)
35#define PORTCORE_SEND_LOG (2)
38#define PORTCORE_IS_NULL (0)
39#define PORTCORE_IS_RPC (1)
40#define PORTCORE_IS_INPUT (2)
41#define PORTCORE_IS_OUTPUT (4)
105 outputModifier(nullptr),
106 inputModifier(nullptr)
112 releaseOutModifier();
118 if (outputModifier !=
nullptr) {
119 outputModifier->
close();
120 delete outputModifier;
121 outputModifier =
nullptr;
127 if (inputModifier !=
nullptr) {
128 inputModifier->
close();
129 delete inputModifier;
130 inputModifier =
nullptr;
165 bool addOutput(
const std::string& dest,
181 void removeInput(
const std::string& src,
191 void removeOutput(
const std::string& dest,
201 bool removeIO(
const Route& route,
bool synch =
false);
239 void setName(
const std::string& name);
244 std::string getName();
251 void setEnvelope(
const std::string& envelope);
258 std::string getEnvelope();
287 this->m_flags =
flags;
292 this->m_contactable = contactable;
321 int getOutputCount();
369 bool start()
override;
374 bool manualStart(
const char* sourceName);
400 void close()
override;
415 const Contact& getAddress()
const;
417 void resetPortName(
const std::string& str);
427 void notifyCompletion(
void*
tracker);
433 void setControlRegistration(
bool flag);
453 void resetReportCallback();
459 bool isListening()
const;
465 bool isManual()
const;
470 bool isInterrupted()
const;
472 void setTimeout(
float timeout);
482 void releaseProperties(
Property* prop);
484 bool setCallbackLock(std::mutex* mutex =
nullptr);
486 bool removeCallbackLock();
490 bool tryLockCallback();
492 void unlockCallback();
500 void promiseType(
const Type&
typ);
504 std::vector<PortCoreUnit *> m_units;
505 std::mutex m_stateMutex;
506 std::condition_variable m_stateCv;
507 std::mutex m_packetMutex;
508 std::condition_variable m_connectionChangeCv;
509 Face* m_face {
nullptr};
516 std::atomic<bool> m_listening {
false};
517 std::atomic<bool> m_running {
false};
518 std::atomic<bool> m_starting {
false};
519 std::atomic<bool> m_closing {
false};
520 std::atomic<bool> m_finished {
false};
521 bool m_finishing {
false};
522 bool m_waitBeforeSend {
true};
523 bool m_waitAfterSend {
true};
524 bool m_controlRegistration {
true};
525 bool m_interruptable {
true};
526 bool m_interrupted {
false};
527 bool m_manual {
false};
529 int m_connectionListeners {0};
530 int m_inputCount {0};
531 int m_outputCount {0};
532 int m_dataOutputCount {0};
534 bool m_logNeeded {
false};
535 PortCorePackets m_packets {};
536 std::string m_envelope;
537 float m_timeout {-1};
541 std::mutex* m_mutex {
nullptr};
542 bool m_mutexOwned {
false};
543 BufferedConnectionWriter m_envelopeWriter {
true};
545 std::mutex m_typeMutex;
546 bool m_checkedType {
false};
553 bool setTypeOfService(PortCoreUnit* unit,
int tos);
556 int getTypeOfService(PortCoreUnit* unit);
560 bool setProcessSchedulingParam(
int priority = -1,
int policy = -1);
566 bool detachPortMonitor(
bool isOutput);
569 bool setParamPortMonitor(
const yarp::os::Property& param,
bool isOutput, std::string& errMsg);
572 bool getParamPortMonitor(
yarp::os::Property& param,
bool isOutput, std::string& errMsg);
576 bool isUnit(
const Route& route,
int index);
582 void cleanUnits(
bool blocking =
true);
588 void addInput(InputProtocol* ip);
590 bool removeUnit(
const Route& route,
bool synch =
false,
bool* except =
nullptr);
#define PORTCORE_IS_INPUT
#define PORTCORE_IS_OUTPUT
A mini-server for performing network communication in the background.
void close() override
Stop port activity.
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.
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.
The components from which ports and connections are built.