39# include <ace/INET_Addr.h>
40# include <ace/Sched_Params.h>
49# include <sys/types.h>
85 std::lock_guard<std::mutex> lock(m_stateMutex);
108 if (m_face ==
nullptr) {
113 if (m_address.
getPort() <= 0) {
122 m_listening.store(
true);
156 m_adminReader = &reader;
190 std::lock_guard<std::mutex> lock(m_stateMutex);
191 m_running.store(
true);
192 m_starting.store(
false);
196 m_stateCv.notify_one();
204 bool shouldStop =
false;
205 while (!shouldStop) {
212 std::lock_guard<std::mutex> lock(m_stateMutex);
224 shouldStop |= m_closing.load();
252 std::lock_guard<std::mutex> lock(m_stateMutex);
253 m_connectionListeners = 0;
254 m_connectionChangeCv.notify_all();
260 std::lock_guard<std::mutex> lock(m_stateMutex);
261 m_connectionListeners = 0;
262 m_connectionChangeCv.notify_all();
263 m_finished.store(
true);
281 std::unique_lock<std::mutex> lock(m_stateMutex);
290 m_starting.store(
true);
300 m_stateCv.wait(lock, [&]{
return m_running.load(); });
317 m_interruptable =
false;
327 m_interrupted =
false;
335 if (!m_listening.load()) {
340 m_interrupted =
true;
345 if (!m_interruptable) {
355 std::lock_guard<std::mutex> lock(m_stateMutex);
356 if (m_reader !=
nullptr) {
367void PortCore::closeMain()
373 std::lock_guard<std::mutex> lock(m_stateMutex);
376 if (m_finishing || !(m_running.load() || m_manual)) {
401 std::lock_guard<std::mutex> lock(m_stateMutex);
402 for (
auto*
unit : m_units) {
403 if ((
unit !=
nullptr) &&
unit->isInput() && !
unit->isDoomed()) {
406 if (s.length() >= 1 && s[0] ==
'/' && s !=
getName() && s !=
prevName) {
436 std::lock_guard<std::mutex> lock(m_stateMutex);
437 for (
auto*
unit : m_units) {
438 if ((
unit !=
nullptr) &&
unit->isOutput() && !
unit->isFinished()) {
457 m_closing.store(
true);
480 std::lock_guard<std::mutex> lock(m_stateMutex);
481 m_finished.store(
false);
482 m_closing.store(
false);
483 m_running.store(
false);
489 if (m_listening.load()) {
494 m_listening.store(
false);
500 if (m_reader !=
nullptr) {
510 if (name != std::string(
"")) {
511 if (m_controlRegistration) {
534 std::lock_guard<std::mutex> lock(m_stateMutex);
540void PortCore::closeUnits()
548 for (
auto& i : m_units) {
550 if (
unit !=
nullptr) {
565void PortCore::reapUnits()
569 if (!m_finished.load()) {
570 std::lock_guard<std::mutex> lock(m_stateMutex);
571 for (
auto*
unit : m_units) {
572 if ((
unit !=
nullptr) &&
unit->isDoomed() && !
unit->isFinished()) {
573 std::string s =
unit->getRoute().toString();
585void PortCore::cleanUnits(
bool blocking)
592 std::unique_lock<std::mutex> lock(m_stateMutex, std::defer_lock);
608 if (!m_finished.load()) {
611 for (
auto& i : m_units) {
613 if (
unit !=
nullptr) {
615 if (
unit->isFinished()) {
616 std::string con =
unit->getRoute().toString();
625 if (!
unit->isDoomed()) {
626 if (
unit->isOutput()) {
628 if (
unit->getMode().empty()) {
632 if (
unit->isInput()) {
633 if (
unit->getRoute().getFromName() !=
"admin") {
646 for (
size_t i2 = 0;
i2 < m_units.size();
i2++) {
647 if (m_units[
i2] !=
nullptr) {
649 m_units[rem] = m_units[
i2];
650 m_units[
i2] =
nullptr;
657 for (
size_t i3 = 0;
i3 < m_units.size() - rem;
i3++) {
666 m_packetMutex.lock();
669 m_packetMutex.unlock();
684 std::lock_guard<std::mutex> lock(m_stateMutex);
691 m_units.push_back(
unit);
708 if (!m_finished.load()) {
709 std::lock_guard<std::mutex> lock(m_stateMutex);
713 m_units.push_back(
unit);
718bool PortCore::isUnit(
const Route& route,
int index)
722 if (!m_finished.load()) {
723 for (
auto*
unit : m_units) {
724 if (
unit !=
nullptr) {
726 std::string
wild =
"*";
729 ok = ok && (
unit->getIndex() == index);
753bool PortCore::removeUnit(
const Route& route,
bool synch,
bool*
except)
770 if (!m_finished.load()) {
771 std::lock_guard<std::mutex> lock(m_stateMutex);
772 for (
auto*
unit : m_units) {
773 if (
unit !=
nullptr) {
775 std::string
wild =
"*";
828 std::unique_lock<std::mutex> lock(m_stateMutex);
830 m_connectionListeners++;
831 m_connectionChangeCv.wait(lock, [&]{
return m_connectionListeners == 0; });
860 bw.appendLine(std::string(
"Do not know how to connect to ") + dest);
878 bw.appendLine(std::string(
"Desired connection already present from ") +
getName() +
" to " + dest);
912 err =
"Logger configured as log." +
mode +
", but only log.in is supported";
915 append =
"; " + r.
getFromName() +
" will forward messages and replies (if any) to " + r.
getToName();
926 err =
"Outputs not allowed";
931 if (m_dataOutputCount >= 1 && !
is_log) {
932 err =
"RPC output already connected";
958 bool ok = op->
open(r);
968 bw.appendLine(std::string(
"Cannot connect to ") + dest);
989 if (!m_finished.load()) {
990 std::lock_guard<std::mutex> lock(m_stateMutex);
997 m_units.push_back(
unit);
1002 bw.appendLine(std::string(
"Added connection from ") +
getName() +
" to " + dest + append);
1003 if (os !=
nullptr) {
1018 const bool removed = removeUnit(
Route(
"*", dest,
"*"),
true);
1020 bw.appendLine(std::string(
"Removed connection from ") +
getName() +
" to " + dest);
1022 bw.appendLine(std::string(
"Could not find an outgoing connection to ") + dest);
1024 if (os !=
nullptr) {
1038 const bool removed = removeUnit(
Route(src,
"*",
"*"),
true);
1040 bw.appendLine(std::string(
"Removing connection from ") + src +
" to " +
getName());
1042 bw.appendLine(std::string(
"Could not find an incoming connection from ") + src);
1044 if (os !=
nullptr) {
1062 std::lock_guard<std::mutex> lock(m_stateMutex);
1065 bw.appendLine(std::string(
"This is ") + m_address.
getRegName() +
" at " + m_address.
toURI());
1069 for (
auto*
unit : m_units) {
1070 if ((
unit !=
nullptr) &&
unit->isOutput() && !
unit->isFinished()) {
1078 bw.appendLine(
"There are no outgoing connections");
1083 for (
auto*
unit : m_units) {
1084 if ((
unit !=
nullptr) &&
unit->isInput() && !
unit->isFinished()) {
1094 bw.appendLine(
"There are no incoming connections");
1099 if (os !=
nullptr) {
1113 std::lock_guard<std::mutex> lock(m_stateMutex);
1118 std::string portName = m_address.
getRegName();
1119 baseInfo.message = std::string(
"This is ") + portName +
" at " + m_address.
toURI();
1124 for (
auto*
unit : m_units) {
1125 if ((
unit !=
nullptr) &&
unit->isOutput() && !
unit->isFinished()) {
1131 info.incoming =
false;
1132 info.portName = portName;
1143 info.message =
"There are no outgoing connections";
1149 for (
auto*
unit : m_units) {
1150 if ((
unit !=
nullptr) &&
unit->isInput() && !
unit->isFinished()) {
1156 info.incoming =
true;
1157 info.portName = portName;
1168 info.message =
"There are no incoming connections";
1176 std::lock_guard<std::mutex> lock(m_stateMutex);
1177 if (reporter !=
nullptr) {
1178 m_eventReporter = reporter;
1184 std::lock_guard<std::mutex> lock(m_stateMutex);
1185 m_eventReporter =
nullptr;
1196 if (m_eventReporter !=
nullptr) {
1214 if (m_reader !=
nullptr && !m_interrupted) {
1215 m_interruptable =
false;
1236 result = m_reader->
read(reader);
1240 m_interruptable =
true;
1245 result = b.
read(reader);
1280 if (m_interrupted || m_finishing) {
1309 std::lock_guard<std::mutex> lock(m_stateMutex);
1312 if (m_finished.load()) {
1319 m_packetMutex.lock();
1322 packet->setContent(&writer,
false, callback);
1323 m_packetMutex.unlock();
1326 for (
auto*
unit : m_units) {
1327 if ((
unit !=
nullptr) &&
unit->isOutput() && !
unit->isFinished()) {
1328 bool log = (!
unit->getMode().empty());
1339 m_packetMutex.lock();
1341 m_packetMutex.unlock();
1345 void* out =
unit->send(writer,
1347 (callback !=
nullptr) ? callback : (&writer),
1348 reinterpret_cast<void*
>(
packet),
1355 if (out !=
nullptr) {
1357 m_packetMutex.lock();
1360 m_packetMutex.unlock();
1363 if (
unit->isFinished()) {
1371 m_packetMutex.lock();
1379 m_packetMutex.unlock();
1384 m_logNeeded =
false;
1390 if (m_waitAfterSend && reader !=
nullptr) {
1400 bool writing =
false;
1404 if (!m_finished.load()) {
1405 std::lock_guard<std::mutex> lock(m_stateMutex);
1406 for (
auto*
unit : m_units) {
1407 if ((
unit !=
nullptr) && !
unit->isFinished() &&
unit->isBusy()) {
1420 m_packetMutex.lock();
1421 int result = m_inputCount;
1422 m_packetMutex.unlock();
1429 m_packetMutex.lock();
1430 int result = m_outputCount;
1431 m_packetMutex.unlock();
1439 m_packetMutex.lock();
1444 m_packetMutex.unlock();
1452 bool ok = envelope.
write(m_envelopeWriter);
1462 m_envelope = envelope;
1463 for (
size_t i = 0; i < m_envelope.length(); i++) {
1466 if (m_envelope[i] < 32) {
1467 m_envelope = m_envelope.substr(0, i);
1482 sis.
add(m_envelope);
1486 sbr.reset(sis,
nullptr, route, 0,
true);
1495 const char* carrier,
1501 style.
quiet = !verbose;
1514 int result =
addr.set(
c.getPort(),
c.getHost().c_str());
1518 result =
addr.set(
c.getPort(),
"127.0.0.1");
1522 result =
addr.set(
c.getPort(),
"127.0.1.1");
1565 std::lock_guard<std::mutex> lock(
m_owner.m_stateMutex);
1567 if ((
unit !=
nullptr) && (isInput ?
unit->isInput() :
unit->isOutput()) && !
unit->isFinished()) {
1570 if (!name.empty()) {
1582 std::lock_guard<std::mutex> lock(
m_owner.m_stateMutex);
1584 if ((
unit !=
nullptr) && (isInput ?
unit->isInput() :
unit->isOutput()) && !
unit->isFinished()) {
1587 result.
found =
true;
1592 if (carrier !=
nullptr) {
1621 result.
params =
property.toString();
1632 if ((
unit !=
nullptr) && (isInput ?
unit->isInput() :
unit->isOutput()) && !
unit->isFinished()) {
1644 return isInput ?
"Could not find an incoming connection from " + portname
1645 :
"Could not find an outgoing connection to " + portname;
1652 std::lock_guard<std::mutex> lock(
m_owner.m_stateMutex);
1654 if (
unit ==
nullptr) {
1661 unit->setCarrierParams(property);
1663 result.
message = (isInput ?
"Configured connection from " :
"Configured connection to ") + portname;
1671 std::lock_guard<std::mutex> lock(
m_owner.m_stateMutex);
1673 if (
unit ==
nullptr) {
1679 unit->getCarrierParams(property);
1681 result.
params =
property.toString();
1690 std::lock_guard<std::mutex> lock(
m_owner.m_stateMutex);
1692 if (
unit !=
nullptr) {
1693 result.
found =
true;
1710 std::lock_guard<std::mutex> lock(
m_owner.m_stateMutex);
1712 if (
unit ==
nullptr) {
1717 if (
unit->setPriority(priority, policy) == -1) {
1719 result.
message =
"Cannot set the scheduling parameters of the thread of the connection";
1725 result.
message =
"Cannot set the type of service of the connection";
1735 return_addConnection addConnection(
const std::string& portname,
const std::string& carrier)
override
1740 const std::string output = carrier.empty() ? portname : carrier +
":/" + portname;
1772 bool attachPortmonitorOut(
const std::string& prop)
override {
return attach(prop,
true); }
1773 bool attachPortmonitorIn(
const std::string& prop)
override {
return attach(prop,
false); }
1774 bool detachPortmonitorOut()
override {
return m_owner.detachPortMonitor(
true); }
1775 bool detachPortmonitorIn()
override {
return m_owner.detachPortMonitor(
false); }
1776 return_setPortmonitorParams setPortmonitorParamsOut(
const std::string& params)
override {
return setPortmonitorParams(params,
true); }
1777 return_setPortmonitorParams setPortmonitorParamsIn(
const std::string& params)
override {
return setPortmonitorParams(params,
false); }
1808 if (processInfo.
pid == -1) {
1818 const unsigned int flags =
m_owner.getFlags();
1827 return_getConnectionQos getConnectionQosIn(
const std::string& portname)
override {
return getConnectionQos(
true, portname); }
1828 return_getConnectionQos getConnectionQosOut(
const std::string& portname)
override {
return getConnectionQos(
false, portname); }
1829 return_setConnectionQos setConnectionQosIn(
const std::string& portname,
const std::int32_t scheduler_priority,
const std::int32_t scheduler_policy,
const std::int32_t qos_tos)
override {
return setConnectionQos(
true, portname, scheduler_priority, scheduler_policy, qos_tos); }
1830 return_setConnectionQos setConnectionQosOut(
const std::string& portname,
const std::int32_t scheduler_priority,
const std::int32_t scheduler_policy,
const std::int32_t qos_tos)
override {
return setConnectionQos(
false, portname, scheduler_priority, scheduler_policy, qos_tos); }
1832 bool setProcessScheduling(
const std::int32_t priority,
const std::int32_t policy)
override
1835 return m_owner.setProcessSchedulingParam(priority, policy);
1856 if (m_adminReader !=
nullptr) {
1868 result.
addString(
"send help for the list of valid commands");
1881 if (writer !=
nullptr) {
1882 result.
write(*writer);
1891 if (
unit ==
nullptr) {
1897 if (
unit->isOutput()) {
1901 if (op !=
nullptr) {
1917 if (
unit->isInput()) {
1921 if ((ip !=
nullptr) && ip->
getOutput().isOk()) {
1923 bool ok = ip->
getOutput().getOutputStream().setTypeOfService(
tos);
1937 if (
unit ==
nullptr) {
1941 if (
unit->isOutput()) {
1945 if (op !=
nullptr) {
1956 if (
unit->isInput()) {
1960 if ((ip !=
nullptr) && ip->
getOutput().isOk()) {
1961 return ip->
getOutput().getOutputStream().getTypeOfService();
1974 errMsg =
"Portmonitor carrier modifier cannot be find or it is not enabled in YARP!";
1982 detachPortMonitor(
true);
1984 prop.
put(
"destination",
"");
1985 prop.
put(
"sender_side", 1);
1986 prop.
put(
"receiver_side", 0);
1987 prop.
put(
"carrier",
"");
1992 errMsg =
"Failed to configure the portmonitor plug-in";
1998 detachPortMonitor(
false);
1999 prop.
put(
"source",
"");
2001 prop.
put(
"sender_side", 0);
2002 prop.
put(
"receiver_side", 1);
2003 prop.
put(
"carrier",
"");
2008 errMsg =
"Failed to configure the portmonitor plug-in";
2018bool PortCore::detachPortMonitor(
bool isOutput)
2039 errMsg =
"No port modifier is attached to the output";
2048 errMsg =
"No port modifier is attached to the input";
2065 errMsg =
"No port modifier is attached to the output";
2074 errMsg =
"No port modifier is attached to the input";
2087 if (
unit !=
nullptr) {
2088 bool isLog = (!
unit->getMode().empty());
2095bool PortCore::setProcessSchedulingParam(
int priority,
int policy)
2097#if defined(__linux__)
2104 sprintf(path,
"/proc/%d/task/", yarp::os::impl::getpid());
2107 if (
dir ==
nullptr) {
2116 if (
isdigit(
static_cast<unsigned char>(*d->d_name)) == 0) {
2121 if (d->d_name == end || ((end !=
nullptr) && (*end != 0))) {
2129#elif defined(YARP_HAS_ACE)
2132 int ret = ACE_OS::set_scheduling_params(param, yarp::os::impl::getpid());
2141 return removeUnit(route, synch);
2154int PortCore::getNextIndex()
2156 int result = m_counter;
2158 if (m_counter < 0) {
2176 return m_readableCreator;
2181 m_controlRegistration = flag;
2186 return m_listening.load();
2196 return m_interrupted;
2201 m_timeout = timeout;
2207 if (mutex !=
nullptr) {
2209 m_mutexOwned =
false;
2211 m_mutex =
new std::mutex;
2212 m_mutexOwned =
true;
2219 if (m_mutexOwned && (m_mutex !=
nullptr)) {
2223 m_mutexOwned =
false;
2229 if (m_mutex ==
nullptr) {
2238 if (m_mutex ==
nullptr) {
2241 return m_mutex->try_lock();
2246 if (m_mutex ==
nullptr) {
2260 if (!m_checkedType) {
2264 m_checkedType =
true;
2266 m_typeMutex.unlock();
2273 m_typeMutex.unlock();
2281 m_typeMutex.unlock();
static bool __tcp_check(const Contact &c)
static bool __pc_rpc(const Contact &c, const char *carrier, Bottle &writer, Bottle &reader, bool verbose)
#define PORTCORE_IS_INPUT
#define PORTCORE_SEND_LOG
#define PORTCORE_IS_OUTPUT
#define PORTCORE_SEND_NORMAL
A simple collection of objects that can be described and transmitted in a portable way.
void addVocab32(yarp::conf::vocab32_t x)
Places a 32 bit vocabulary item in the bottle, at the end of the list.
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
bool write(ConnectionWriter &writer) const override
Output a representation of the bottle to a network connection.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
std::string toString() const override
Gives a human-readable textual representation of the bottle.
A mini-server for performing network communication in the background.
Type getType() override
Get the type of data the port has committed to send/receive.
std::string getName() const override
Get name of port.
void close() override
Stop port activity.
T * read(bool shouldWait=true) override
Read an available object from the port.
bool addOutput(const std::string &name) override
Add an output connection to the specified port.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
A base class for connection types (tcp, mcast, shmem, ...) which are called carriers in YARP.
bool isConnectionless() const override=0
Check if this carrier is connectionless (like udp, mcast) or connection based (like tcp).
void getCarrierParams(Property ¶ms) const override
Get carrier configuration and deliver it by port administrative commands.
virtual bool configureFromProperty(yarp::os::Property &options)
bool isPush() const override
Check if carrier is "push" or "pull" style.
bool acceptOutgoingData(const PortWriter &writer) override
Determine whether outgoing data should be accepted.
const PortWriter & modifyOutgoingData(const PortWriter &writer) override
Modify outgoing payload data, if appropriate.
void setCarrierParams(const Property ¶ms) override
Configure carrier from port administrative commands.
static Face * listen(const Contact &address)
Create a "proto-carrier" interface object that waits for incoming connections prior to a carrier bein...
static Carrier * getCarrierTemplate(const std::string &name)
Get template for carrier.
static Carrier * chooseCarrier(const std::string &name)
Select a carrier by name.
static OutputProtocol * connect(const Contact &address)
Initiate a connection to an address.
An interface for reading from a network connection.
virtual ConnectionWriter * getWriter()=0
Gets a way to reply to the message, if possible.
An interface for writing to a network connection.
A dummy connection to test yarp::os::Portable implementations.
ConnectionWriter & getWriter()
Get the dummy ConnectionWriter loaded with whatever was written the ConnectionWriter since it was las...
ConnectionReader & getReader(ConnectionWriter *replyWriter=nullptr)
Get the dummy ConnectionReader loaded with whatever was written the ConnectionWriter since it was las...
virtual InputProtocol * read()=0
Block and wait for someone to talk to us.
virtual Contact getLocalAddress() const
Get address after open(), if more specific that the address provided to open() - otherwise an invalid...
virtual OutputProtocol * write(const Contact &address)=0
Try to reach out and talk to someone.
virtual void close()=0
Stop listening.
Simple abstraction for a YARP port name.
Contact toAddress() const
Create an address from the name.
std::string getCarrierModifier(const char *mod, bool *hasModifier=nullptr)
static bool initialized()
Returns true if YARP has been fully initialized.
static bool getLocalMode()
Get current value of flag "localMode", see setLocalMode function.
static Contact unregisterName(const std::string &name)
Removes the registration for a name from the name server.
static NameStore * getQueryBypass()
static Contact queryName(const std::string &name)
Find out information about a registered name.
static int disconnectInput(const std::string &src, const std::string &dest, bool silent=false)
Sends a disconnection command to the specified port.
static bool writeToNameServer(PortWriter &cmd, PortReader &reply, const ContactStyle &style)
Variant write method specialized to name server.
static bool disconnect(const std::string &src, const std::string &dest, bool quiet)
Request that an output port disconnect from an input port.
static bool write(const Contact &contact, PortWriter &cmd, PortReader &reply, bool admin=false, bool quiet=false, double timeout=-1)
Send a single command to a port and await a single response.
The output side of an active connection between two ports.
virtual OutputStream & getOutputStream()=0
Access the output stream associated with the connection.
virtual Connection & getConnection()=0
Get the connection whose protocol operations we are managing.
virtual bool open(const Route &route)=0
Start negotiating a carrier, using the given route (this should generally match the name of the sendi...
virtual void attachPort(Contactable *port)=0
Set the port to be associated with the connection.
virtual InputProtocol & getInput()=0
Get an interface for doing read operations on the connection.
virtual void close()=0
Negotiate an end to operations.
virtual void rename(const Route &route)=0
Relabel the route after the fact (e.g.
virtual bool setTimeout(double timeout)=0
Set the timeout to be used for network operations.
Simple specification of the minimum functions needed from output streams.
Administrative commands of a YARP port, handled by PortCore::adminBlock().
Information about a port connection or event.
std::string message
A human-readable description of contents.
int tag
Type of information.
@ PORTINFO_CONNECTION
Information about an incoming or outgoing connection.
@ PORTINFO_MISC
Unspecified information.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
virtual bool read(ConnectionReader &reader)=0
Read this object from a network connection.
virtual Type getReadType() const
A base class for objects that want information about port status changes.
virtual void report(const PortInfo &info)=0
Callback for port event/state information.
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
virtual bool write(ConnectionWriter &writer) const =0
Write this object to a network connection.
virtual void onCommencement() const
This is called when the port is about to begin writing operations.
Holds the operating system process information.
A class for storing options and configuration information.
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
Information about a connection between two ports.
const std::string & getToName() const
Get the destination of the route.
const std::string & getCarrierName() const
Get the carrier type of the route.
std::string toString() const
Render a text form of the route, "source->carrier->dest".
const std::string & getFromName() const
Get the source of the route.
void swapNames()
Swap from and to names.
void setToContact(const Contact &toContact)
Set the destination contact of the route.
An OutputStream that produces a string.
std::string toString() const
static ProcessInfo getProcessInfo(int pid=0)
gets the operating system process information given by its PID.
static PlatformInfo getPlatformInfo()
getPlatformInfo
std::string getName() const
A helper for creating cached object descriptions.
std::string toString() const
void restart()
Tell the writer that we will be serializing a new object, but to keep any cached buffers that already...
A helper for recording entire message/reply transactions.
Manager for a single output from a port.
A single message, potentially being transmitted on multiple connections.
PortCorePacket * getFreePacket()
Get a packet that we can prepare for sending.
bool checkPacket(PortCorePacket *packet)
Move a packet to the inactive state if it has finished being sent on all connections.
This manages a single threaded resource related to a single input or output connection.
void notifyCompletion(void *tracker)
Call the right onCompletion() after sending message.
void resetPortName(const std::string &str)
std::string getEnvelope()
void setAdminReadHandler(yarp::os::PortReader &reader)
Set a callback for incoming administrative messages.
int getOutputCount()
Check how many output connections there are.
bool readBlock(ConnectionReader &reader, void *id, yarp::os::OutputStream *os)
Read a block of regular payload data.
void setReportCallback(yarp::os::PortReport *reporter)
Set a callback to be notified of changes in port status.
void run() override
The body of the main thread.
bool start() override
Begin main thread.
void checkType(PortReader &reader)
void resume()
Undo an interrupt()
void setTimeout(float timeout)
yarp::os::PortReaderCreator * getReadCreator()
Get the creator of callbacks.
void interrupt()
Prepare the port to be shut down.
bool removeInput(const std::string &src, void *id, yarp::os::OutputStream *os)
Remove an input connection.
bool setCallbackLock(std::mutex *mutex=nullptr)
void setEnvelope(const std::string &envelope)
Set some envelope information to pass along with a message without actually being part of the message...
bool removeIO(const Route &route, bool synch=false)
Remove any connection matching the supplied route.
bool isInterrupted() const
void report(const yarp::os::PortInfo &info)
Handle a port event (connection, disconnection, etc) Generate a description of the connections associ...
bool listen(const Contact &address, bool shouldAnnounce=true)
Begin service at a given address.
bool sendHelper(const yarp::os::PortWriter &writer, int mode, yarp::os::PortReader *reader=nullptr, const yarp::os::PortWriter *callback=nullptr)
Send a message with a specific mode (normal or log).
void setControlRegistration(bool flag)
Normally the port will unregister its name with the name server when shutting down.
int getInputCount()
Check how many input connections there are.
bool manualStart(const char *sourceName)
Start up the port, but without a main thread.
void setReadHandler(yarp::os::PortReader &reader)
Set a callback for incoming data.
void reportUnit(PortCoreUnit *unit, bool active)
Called by a connection handler with active=true just after it is fully configured,...
bool removeOutput(const std::string &dest, void *id, yarp::os::OutputStream *os)
Remove an output connection.
void promiseType(const Type &typ)
int getEventCount()
A diagnostic for testing purposes.
void close() override
Shut down port.
const Contact & getAddress() const
Get the address associated with the port.
void describe(void *id, yarp::os::OutputStream *os)
Produce a text description of the port and its connections.
bool isWriting()
Check if a message is currently being sent.
bool adminBlock(ConnectionReader &reader, void *id)
Read a block of administrative data.
unsigned int getFlags()
Check current configuration of port.
bool send(const yarp::os::PortWriter &writer, yarp::os::PortReader *reader=nullptr, const yarp::os::PortWriter *callback=nullptr)
Send a normal message.
void resetReportCallback()
Reset the callback to be notified of changes in port status.
void setReadCreator(yarp::os::PortReaderCreator &creator)
Set a callback for creating callbacks for incoming data.
yarp::os::impl::PortDataModifier & getPortModifier()
void setName(const std::string &name)
Set the name of this port.
bool removeCallbackLock()
bool addOutput(const std::string &dest, void *id, yarp::os::OutputStream *os, bool onlyIfNeeded=false)
Add an output connection to this port.
This is the heart of a yarp port.
yarp::os::Carrier * outputModifier
yarp::os::Carrier * inputModifier
void releaseOutModifier()
Lets Readable objects read from the underlying InputStream associated with the connection between two...
int join(double seconds=-1)
Reply of PortCoreMsgs::addConnection().
Reply of PortCoreMsgs::delConnection().
Reply of PortCoreMsgs::getAdminProtocolVersion().
std::int32_t version_minor
std::int32_t version_major
std::int32_t version_patch
Reply of PortCoreMsgs::getConnectionInfoIn() and PortCoreMsgs::getConnectionInfoOut().
Reply of PortCoreMsgs::getConnectionParamsIn() and PortCoreMsgs::getConnectionParamsOut().
Reply of PortCoreMsgs::getConnectionQosIn() and PortCoreMsgs::getConnectionQosOut().
yarp::os::ThreadInfoData thread
Reply of PortCoreMsgs::getPortInfo().
yarp::os::ProcessInfoData process
yarp::os::ThreadInfoData thread
yarp::os::PortInfoData port
yarp::os::PlatformInfoData platform
Reply of PortCoreMsgs::getPortmonitorParamsIn() and PortCoreMsgs::getPortmonitorParamsOut().
Reply of PortCoreMsgs::listConnectionsIn() and PortCoreMsgs::listConnectionsOut().
std::vector< std::string > connections
Reply of PortCoreMsgs::setConnectionParamsIn() and PortCoreMsgs::setConnectionParamsOut().
Reply of PortCoreMsgs::setConnectionQosIn() and PortCoreMsgs::setConnectionQosOut().
Reply of PortCoreMsgs::setPortmonitorParamsIn() and PortCoreMsgs::setPortmonitorParamsOut().
#define yCIAssert(component, id, x)
#define yCWarning(component,...)
#define yCIError(component, id,...)
#define yCITrace(component, id,...)
#define yCIDebug(component, id,...)
#define yCIWarning(component, id,...)
#define YARP_OS_LOG_COMPONENT(name, name_string)
std::string to_string(IntegerType x)
The components from which ports and connections are built.
An interface to the operating system, including Port based communication.
The main, catch-all namespace for YARP.