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,
182 bool removeInput(
const std::string& src,
193 bool removeOutput(
const std::string& dest,
203 bool removeIO(
const Route& route,
bool synch =
false);
241 void setName(
const std::string& name);
246 std::string getName();
253 void setEnvelope(
const std::string& envelope);
260 std::string getEnvelope();
289 this->m_flags = flags;
323 int getOutputCount();
371 bool start()
override;
376 bool manualStart(
const char* sourceName);
402 void close()
override;
417 const Contact& getAddress()
const;
419 void resetPortName(
const std::string& str);
429 void notifyCompletion(
void*
tracker);
435 void setControlRegistration(
bool flag);
455 void resetReportCallback();
461 bool isListening()
const;
467 bool isManual()
const;
472 bool isInterrupted()
const;
474 void setTimeout(
float timeout);
476 bool setCallbackLock(std::mutex* mutex =
nullptr);
478 bool removeCallbackLock();
482 bool tryLockCallback();
484 void unlockCallback();
492 void promiseType(
const Type&
typ);
496 std::vector<PortCoreUnit *> m_units;
497 std::mutex m_stateMutex;
498 std::condition_variable m_stateCv;
499 std::mutex m_packetMutex;
500 std::condition_variable m_connectionChangeCv;
501 Face* m_face {
nullptr};
508 std::atomic<bool> m_listening {
false};
509 std::atomic<bool> m_running {
false};
510 std::atomic<bool> m_starting {
false};
511 std::atomic<bool> m_closing {
false};
512 std::atomic<bool> m_finished {
false};
513 bool m_finishing {
false};
514 bool m_waitBeforeSend {
true};
515 bool m_waitAfterSend {
true};
516 bool m_controlRegistration {
true};
517 bool m_interruptable {
true};
518 bool m_interrupted {
false};
519 bool m_manual {
false};
521 int m_connectionListeners {0};
522 int m_inputCount {0};
523 int m_outputCount {0};
524 int m_dataOutputCount {0};
526 bool m_logNeeded {
false};
527 PortCorePackets m_packets {};
528 std::string m_envelope;
529 float m_timeout {-1};
532 std::mutex* m_mutex {
nullptr};
533 bool m_mutexOwned {
false};
534 BufferedConnectionWriter m_envelopeWriter {
true};
536 std::mutex m_typeMutex;
537 bool m_checkedType {
false};
544 bool setTypeOfService(PortCoreUnit* unit,
int tos);
547 int getTypeOfService(PortCoreUnit* unit);
551 bool setProcessSchedulingParam(
int priority = -1,
int policy = -1);
554 bool attachPortMonitor(
const std::string& portmonitor_options,
bool isOutput, std::string& errMsg);
557 bool detachPortMonitor(
bool isOutput);
560 bool setParamPortMonitor(
const yarp::os::Property& param,
bool isOutput, std::string& errMsg);
563 bool getParamPortMonitor(
yarp::os::Property& param,
bool isOutput, std::string& errMsg);
567 bool isUnit(
const Route& route,
int index);
573 void cleanUnits(
bool blocking =
true);
579 void addInput(InputProtocol* ip);
581 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.