|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
38 # include <ace/Init_ACE.h>
39 # include <ace/config.h>
91 return __multi_name_space;
96 if (!contact.
getHost().empty()) {
108 if (store !=
nullptr) {
136 "enactConnection: SRC %s DST %s using carrier %s, MODE=%d, rev=%d",
152 yCError(NETWORK,
"Failure: cannot check subscriptions yet");
159 yCInfo(NETWORK,
"Success: port-to-port persistent connection added.");
175 if (reply.
check(
"carrier")) {
179 "Connection found between %s and %s using carrier %s",
185 return (carrier == style.
carrier) ? 0 : 1;
192 bool currentIsConnectionLess =
false;
193 bool currentIsPush =
true;
194 if (reply.
check(
"push")) {
197 if (reply.
check(
"connectionless")) {
198 currentIsConnectionLess = reply.
find(
"connectionless").
asBool();
200 if (currentIsConnectionLess && ((reversed && currentIsPush) || (!reversed && !currentIsPush))) {
245 ok = msg[0] ==
'A' || msg[0] ==
'R';
248 msg =
"no such connection";
255 yCError(NETWORK,
"%s %s",
"Failure:", msg.c_str());
257 yCInfo(NETWORK,
"%s %s",
"Success:", msg.c_str());
266 auto pos = carrier_name.find(
'+');
267 if (pos != std::string::npos) {
268 return carrier_name.substr(pos);
275 return carrier_name_with_params.substr(0, carrier_name_with_params.find(
'+'));
296 const std::string& dest,
301 "working on connection %s to %s (%s)",
306 if (dest.find(
' ') != std::string::npos || src.find(
' ') != std::string::npos) {
308 "Failure: no way to make connection %s->%s, one of the port names contains a space character.",
315 "METACONNECT: src=%s dest=%s style=%s",
325 "DYNAMIC_SRC: name=%s, carrier=%s",
329 "DYNAMIC_DST: name=%s, carrier=%s",
335 "Failure: no way to make connection, invalid source '%s'",
341 "Failure: no way to make connection, invalid destination '%s'",
342 dynamicDest.
getName().c_str());
356 if (
needsLookup(dynamicSrc) && (topicalNeedsLookup || !topical)) {
362 "Failure: could not find source port %s",
367 staticSrc = dynamicSrc;
370 staticSrc = dynamicSrc;
379 if (
needsLookup(dynamicDest) && (topicalNeedsLookup || !topical)) {
385 "Failure: could not find destination port %s",
390 staticDest = dynamicDest;
393 staticDest = dynamicDest;
397 "STATIC_SRC: name=%s, carrier=%s",
401 "STATIC_DST: name=%s, carrier=%s",
415 std::string carrierConstraint;
418 bool srcIsCompetent =
false;
419 bool srcIsTopic =
false;
424 "staticSrc.getCarrier = %s",
429 if (srcCarrier !=
nullptr) {
431 "srcCarrier is NOT null; its name is %s",
432 srcCarrier->
getName().c_str());
434 if (!srcBootstrap.empty()) {
437 "it is competent (bootstrapname is %s), while its name is %s",
438 srcBootstrap.c_str(),
439 srcCarrier->
getName().c_str());
440 srcIsCompetent =
true;
446 "it is NOT competent. its constraint is %s",
447 carrierConstraint.c_str());
450 srcCarrier =
nullptr;
458 bool destIsCompetent =
false;
459 bool destIsTopic =
false;
462 Carrier* destCarrier =
nullptr;
464 "staticDest.getCarrier = %s",
469 if (destCarrier !=
nullptr) {
471 "destCarrier is NOT null; its name is %s",
472 destCarrier->
getName().c_str());
474 if (!destBootstrap.empty()) {
476 "it is competent (bootstrapname is %s), while its name is %s",
477 destBootstrap.c_str(),
478 destCarrier->
getName().c_str());
479 destIsCompetent =
true;
485 "it is NOT competent. its constraint is %s",
486 carrierConstraint.c_str());
489 destCarrier =
nullptr;
496 if (srcIsTopic || destIsTopic) {
508 yCError(NETWORK,
"Failure: cannot check subscriptions yet");
517 yCError(NETWORK,
"Failure: cannot check subscriptions yet");
533 "dynamicSrc.getCarrier() = %s",
536 "dynamicDest.getCarrier() = %s",
539 "staticSrc.getCarrier() = %s",
542 "staticDest.getCarrier() = %s",
545 "carrierConstraint is %s",
546 carrierConstraint.c_str());
549 "style.carrier (1) is %s",
556 "style.carrier is %s ==> in connect command the user specified the carrier of src port",
563 "style.carrier is %s ==> in connect command the user specified the carrier of dest port or the carrier of the connection",
568 "at the end style style.carrier is %s",
573 if (!style.
carrier.empty() && !carrierConstraint.empty()) {
580 if (style_carrier_name != carrier_constraint_name) {
581 yCError(NETWORK,
"Failure: conflict between %s and %s", style_carrier_name.c_str(), carrier_constraint_name.c_str());
585 "style_carrier_name=%s and carrier_constraint_name=%s are equals!",
586 style_carrier_name.c_str(),
587 carrier_constraint_name.c_str());
591 if (!carrierConstraint.empty()) {
592 style.
carrier = carrierConstraint;
596 "if I'm here means that source or dest is not competent");
610 "if I'm here means that both src and dest are compentent and the user didn't specified a carrier in the connect command");
619 yCTrace(NETWORK,
"the chosen style carrier is static src");
625 "style_carrier with params =%s",
628 bool connectionIsPush =
false;
629 bool connectionIsPull =
false;
630 Carrier* connectionCarrier =
nullptr;
631 if (style.
carrier !=
"topic") {
633 if (connectionCarrier !=
nullptr) {
634 connectionIsPush = connectionCarrier->
isPush();
635 connectionIsPull = !connectionIsPush;
640 if ((srcIsCompetent && connectionIsPush) || topical) {
643 delete connectionCarrier;
646 if (destIsCompetent && connectionIsPull) {
648 delete connectionCarrier;
652 if (connectionCarrier !=
nullptr) {
653 if (!connectionIsPull) {
655 result = connectionCarrier->
connect(staticSrc, c, style, mode,
false);
658 result = connectionCarrier->
connect(staticDest, c, style, mode,
true);
661 if (connectionCarrier !=
nullptr) {
662 delete connectionCarrier;
663 connectionCarrier =
nullptr;
669 yCInfo(NETWORK,
"Success: added connection using custom carrier method");
672 yCError(NETWORK,
"Failure: custom carrier method did not work");
679 yCError(NETWORK,
"Failure: no way to make connection %s->%s", src.c_str(), dest.c_str());
685 bool NetworkBase::connect(
const std::string& src,
const std::string& dest,
const std::string& carrier,
bool quiet)
689 if (!carrier.empty()) {
692 return connect(src, dest, style);
696 const std::string& dest,
704 const std::string& dest,
709 return disconnect(src, dest, style);
713 const std::string& dest,
724 if (!carrier.empty()) {
727 return disconnect(src, dest, style);
731 const std::string& dest,
736 return isConnected(src, dest, style);
743 if (!carrier.empty()) {
746 return isConnected(src, dest, style);
753 return exists(port, style, checkVer);
758 bool silent = style.
quiet;
762 yCInfo(NETWORK,
"Address of port %s is not valid", port.c_str());
773 if (out ==
nullptr) {
775 yCInfo(NETWORK,
"Cannot connect to port %s", port.c_str());
813 yCInfo(NETWORK,
"Waiting for %s->%s...", source.c_str(), destination.c_str());
835 yCInfo(NETWORK,
"Waiting for %s...", target.c_str());
840 bool result = exists(target,
true,
false);
852 bool result = waitPort(port, quiet);
870 initMinimum(clockType);
884 #if defined(YARP_HAS_ACE)
900 static YARP_ACE& init()
915 yarp::os::impl::signal(SIGPIPE, SIG_IGN);
966 if (!clock.empty()) {
975 yCDebug(NETWORK,
"Using SYSTEM clock");
980 yCDebug(NETWORK,
"Using NETWORK clock");
987 yCDebug(NETWORK,
"Using CUSTOM clock");
993 yCFatal(NETWORK,
"yarpClockInit called with unknown clock type. Quitting");
1000 yCDebug(NETWORK,
"query name %s", name.c_str());
1001 if (getNameServerName() == name) {
1002 yCDebug(NETWORK,
"query recognized as name server: %s", name.c_str());
1003 return getNameServerContact();
1015 yCDebug(NETWORK,
"register name %s", name.c_str());
1070 #ifndef YARP_NO_DEPRECATED // Since YARP 3.0.0
1075 #endif // YARP_NO_DEPRECATED
1079 return setConnectionQos(src, dest, style, style, quiet);
1105 bool ret =
write(srcCon, cmd, reply,
true,
true, 2.0);
1108 yCError(NETWORK,
"Cannot write to '%s'", src.c_str());
1114 yCError(NETWORK,
"Cannot set qos properties of '%s'. (%s)", src.c_str(), reply.
toString().c_str());
1138 bool ret =
write(destCon, cmd, reply,
true,
true, 2.0);
1141 yCError(NETWORK,
"Cannot write to '%s'", dest.c_str());
1147 yCError(NETWORK,
"Cannot set qos properties of '%s'. (%s)", dest.c_str(), reply.
toString().c_str());
1170 yCError(NETWORK,
"Cannot write to '%s'", port.c_str());
1176 yCError(NETWORK,
"Cannot get qos properties of '%s'. (%s)", port.c_str(), reply.
toString().c_str());
1194 if (!
getPortQos(src, dest, srcStyle, quiet)) {
1197 if (!
getPortQos(dest, src, destStyle, quiet)) {
1205 if (portName.empty()) {
1209 if (portName ==
"...") {
1213 if (portName.at(0) !=
'/') {
1217 if (portName.at(portName.size() - 1) ==
'/') {
1221 if (portName.find(
' ') != std::string::npos) {
1237 style.
admin = admin;
1238 style.
quiet = quiet;
1241 return write(contact, cmd, reply, style);
1261 yCError(NETWORK,
"Cannot make connection to '%s'", ec.
toString().c_str());
1266 bool ok = port.
write(cmd, reply);
1270 const char* connectionName =
"admin";
1271 std::string name = contact.
getName();
1272 const char* targetName = name.c_str();
1279 yCError(NETWORK,
"cannot find port %s", targetName);
1288 if (out ==
nullptr) {
1290 yCError(NETWORK,
"Cannot connect to port %s", targetName);
1298 Route r(connectionName, targetName, (!style.
carrier.empty()) ? style.
carrier.c_str() :
"text_ack");
1310 yCError(NETWORK,
"could not write to connection");
1318 yCError(NETWORK,
"could not write to connection");
1327 if (out !=
nullptr) {
1346 yCInfo(NETWORK,
"No connection from %s to %s found",
1397 #ifndef YARP_NO_DEPRECATED // Since YARP 3.4
1400 if (verbosity < 0) {
1403 }
else if (verbosity == 0) {
1420 #ifndef YARP_NO_DEPRECATED // Since YARP 3.4.0
1440 #ifndef YARP_NO_DEPRECATED // Since YARP 3.3.0
1452 #endif // YARP_NO_DEPRECATED
1455 std::mutex& getNetworkMutex()
1457 static std::mutex mutex;
1464 getNetworkMutex().lock();
1469 getNetworkMutex().unlock();
1478 return sendMessage(port, writable, output, silent);
1483 std::string& output,
1490 yCError(NETWORK,
"Cannot find port named %s", port.c_str());
1495 if (out ==
nullptr) {
1497 yCError(NETWORK,
"Cannot connect to port named %s at %s", port.c_str(), srcAddress.
toURI().c_str());
1501 Route route(
"admin", port,
"text");
1504 bool ok = out->
open(route);
1507 yCError(NETWORK,
"Cannot make connection");
1515 bool wok = writable.
write(bw);
1518 yCError(NETWORK,
"Cannot write on connection");
1523 if (!disconnect.
write(bw)) {
1525 yCError(NETWORK,
"Cannot write on connection");
1552 return sendMessage(target, pc, silent);
1556 const std::string& dest,
1560 return sendMessage(src, pc, silent);
1588 if (factory ==
nullptr) {
1623 return getContent().isTextMode();
1628 return getContent().isBareMode();
1633 return getContent().canEscape();
1638 getContent().handleEnvelope(envelope);
1643 return getContent().requireAck();
1648 return getContent().supportReply();
1653 return getContent().isLocal();
1658 return getContent().isPush();
1663 return getContent().isConnectionless();
1668 return getContent().isBroadcast();
1673 return getContent().isActive();
1678 return getContent().modifiesIncomingData();
1683 return getContent().modifyIncomingData(reader);
1688 return getContent().acceptIncomingData(reader);
1693 return getContent().modifiesOutgoingData();
1698 return getContent().modifyOutgoingData(writer);
1703 return getContent().acceptOutgoingData(writer);
1708 return getContent().modifiesReply();
1713 return getContent().modifyReply(reader);
1718 getContent().setCarrierParams(params);
1723 getContent().getCarrierParams(params);
1728 getContent().getHeader(header);
1733 getContent().prepareDisconnect();
1738 return getContent().getName();
1746 return getContent().checkHeader(header);
1751 getContent().setParameters(header);
1756 return getContent().canAccept();
1761 return getContent().canOffer();
1766 return getContent().prepareSend(proto);
1771 return getContent().sendHeader(proto);
1776 return getContent().expectReplyToHeader(proto);
1781 return getContent().write(proto, writer);
1786 return getContent().reply(proto, writer);
1791 return getContent().expectExtraHeader(proto);
1796 return getContent().respondToHeader(proto);
1801 return getContent().expectIndex(proto);
1806 return getContent().expectSenderSpecifier(proto);
1811 return getContent().sendAck(proto);
1816 return getContent().expectAck(proto);
1821 return getContent().toString();
1826 getContent().close();
1831 return getContent().getBootstrapCarrierName();
1838 bool reversed)
override
1840 return getContent().connect(src, dest, style, mode, reversed);
1845 return getContent().configure(proto);
1849 return getContent().configureFromProperty(options);
1854 return getContent().createFace();
1883 if (plugin.
open(settings)) {
1892 return car.getContent();
1897 return car.getContent();
1903 if (ncar ==
nullptr) {
1906 if (!ncar->isValid()) {
1929 if (dll ==
nullptr) {
1931 if (factory ==
nullptr) {
1937 if (factory ==
nullptr) {
1938 yCError(NETWORK,
"Failed to register carrier");
1942 if (dll !=
nullptr) {
1943 yCError(NETWORK,
"Failed to find library %s with carrier %s", dll, name);
1945 yCError(NETWORK,
"Failed to find library support for carrier %s", name);
1959 return !globalAlloc;
1975 if (!nameServerContact.
getName().empty()) {
1976 setNameServerName(nameServerContact.
getName());
1980 bool result = nameConfig.
toFile();
1991 if (store !=
nullptr) {
1993 return store->
process(cmd, reply, contact);
2008 if (!range.empty()) {
bool isValid() const override
Check if this object is really a connection, or just an empty placeholder.
static bool addCarrierPrototype(Carrier *carrier)
Add a new connection type.
std::string getConfigFileName(const char *stem=nullptr, const char *ns=nullptr)
@ YARP_CLOCK_UNINITIALIZED
A simple collection of objects that can be described and transmitted in a portable way.
static Contact registerContact(const Contact &contact)
Register contact information with the name server.
void getCarrierParams(Property ¶ms) const override
Get carrier configuration and deliver it by port administrative commands.
static void setVerbosity(int verbosity)
Set level of verbosity of YARP messages.
bool isBroadcast() const override
Check if this carrier uses a broadcast mechanism.
std::string toString() const override
Gives a human-readable textual representation of the bottle.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
bool acceptIncomingData(ConnectionReader &reader) override
Determine whether incoming data should be accepted.
static bool waitConnection(const std::string &source, const std::string &destination, bool quiet=false)
Delays the system until a specified connection is established.
constexpr yarp::conf::vocab32_t createVocab(char a, char b=0, char c=0, char d=0)
void clear()
Empties the bottle of any objects it contains.
bool expectSenderSpecifier(ConnectionState &proto) override
Expect the name of the sending port.
Carrier * create() const override
Factory method.
bool modifiesReply() const override
Check if this carrier modifies outgoing data through the Carrier::modifyReply method.
virtual bool writeToNameServer(PortWriter &cmd, PortReader &reply, const ContactStyle &style) override
Write a message to a name server for this NameSpace, if applicable.
void handleEnvelope(const std::string &envelope) override
Carriers that do not distinguish data from administrative headers (i.e.
static std::string getEnvironment(const char *key, bool *found=nullptr)
Read a variable from the environment.
static NameStore * getQueryBypass()
static bool setNameServerName(const std::string &name)
Set the name of the port associated with the nameserver (usually "/root", but this can be overwritten...
static bool setConnectionQos(const std::string &src, const std::string &dest, const QosStyle &srcStyle, const QosStyle &destStyle, bool quiet=true)
Adjust the Qos preferences of a connection.
Preferences for the port's Quality of Service.
size_type size() const
Gets the number of elements in the bottle.
bool expectIndex(ConnectionState &proto) override
Expect a message header, if there is one for this carrier.
static bool getConnectionQos(const std::string &src, const std::string &dest, QosStyle &srcStyle, QosStyle &destStyle, bool quiet=true)
Gets the Qos preferences of a connection.
virtual void queryBypass(NameStore *store)
Set an alternative place to make name queries.
A base class for connection types (tcp, mcast, shmem, ...) which are called carriers in YARP.
The output side of an active connection between two ports.
bool canOffer() const override
Check if writing is implemented for this carrier.
bool expectAck(ConnectionState &proto) override
Receive an acknowledgement, if expected for this carrier.
Abstract interface for a database of port names.
std::string getBootstrapCarrierName() const override
Get the name of the carrier that should be used prior to handshaking, if a port is registered with th...
static void lock()
Call wait() on a global mutual-exclusion semaphore allocated by YARP.
Contact queryName(const std::string &name) override
Map from port name to contact information.
static int __yarp_is_initialized
bool isTextMode() const override
Check if carrier is textual in nature.
static std::string getConfigFile(const char *fname)
Search for a configuration file in YARP's standard config file path.
virtual Carrier * create() const =0
Factory method.
bool expectReplyToHeader(ConnectionState &proto) override
Process reply to header, if one is expected for this carrier.
std::string getEnvironment(const char *key, bool *found=nullptr)
Read a variable from the environment.
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.
bool open(YarpPluginSettings &settings)
Load a library and prepare an object factory, based on the hints supplied.
int getThreadPriority() const
returns the communication thread priority level
virtual bool isBareMode() const
Check if carrier excludes type information from payload.
static void assertion(bool shouldBeTrue)
An assertion.
static bool setProperty(const char *name, const char *key, const Value &value)
Names registered with the nameserver can have arbitrary key->value properties associated with them.
int removeRef()
Decrement the reference count of this factory.
bool writeConfig(const std::string &fileName, const std::string &text)
static bool writeToNameServer(PortWriter &cmd, PortReader &reply, const ContactStyle &style)
Variant write method specialized to name server.
static bool __yarp_auto_init_active
void setParameters(const yarp::os::Bytes &header) override
Configure this carrier based on the first 8 bytes of the connection.
int getThreadPolicy() const
returns the communication thread scheduling policy
int connect(const yarp::os::Contact &src, const yarp::os::Contact &dest, const yarp::os::ContactStyle &style, int mode, bool reversed) override
Some carrier types may require special connection logic.
std::string getDllName() const
Contact registerContact(const Contact &contact) override
Record contact information (should include a port name).
static Carrier * chooseCarrier(const std::string &name)
Select a carrier by name.
std::string getName() const override
Get the name of this connection type ("tcp", "mcast", "shmem", ...)
virtual const Carrier & getContent() const
const PortWriter & modifyOutgoingData(const PortWriter &writer) override
Modify outgoing payload data, if appropriate.
void startTurboBoost()
For OS where it makes sense sets the scheduler to be called more often.
Simple Readable and Writable object representing a command to a YARP port.
static bool sync(const std::string &port, bool quiet=true)
Wait for a port to be ready and responsive.
virtual bool isTextMode() const =0
Check if carrier is textual in nature.
A helper for creating cached object descriptions.
virtual std::string getName() const =0
Get the name of this connection type ("tcp", "mcast", "shmem", ...)
virtual NameStore * getQueryBypass()
Get any alternative place to make name queries, if one was set by queryBypass()
void setAdminMode(bool adminMode=true)
Turn on/off "admin" mode.
static constexpr value_type path_separator
bool isPush() const override
Check if carrier is "push" or "pull" style.
static void initMinimum()
Basic system initialization, not including plugins.
virtual bool close()
Destroy an instance if one has been created.
Pick out a set of relevant plugins.
virtual InputProtocol & getInput()=0
Get an interface for doing read operations on the connection.
void getHeader(yarp::os::Bytes &header) const override
Provide 8 bytes describing this connection sufficiently to allow the other side of a connection to se...
const Carrier & getContent() const override
bool isActive() const override
Check if carrier is alive and error free.
bool reply(ConnectionState &proto, SizedWriter &writer) override
virtual bool process(PortWriter &in, PortReader &out, const Contact &source)=0
Information about a connection between two ports.
bool isPush() const override
Check if carrier is "push" or "pull" style.
static bool rpc(const Contact &c, const char *carrier, Bottle &writer, Bottle &reader)
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
virtual bool canEscape() const =0
Check if carrier can encode administrative messages, as opposed to just user data.
bool respondToHeader(ConnectionState &proto) override
Respond to the header.
SharedLibraryClassFactory< T > * getFactory() const
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
std::string getNamespace(bool refresh=false)
static bool isValidPortName(const std::string &portName)
Checks that the port has a valid name.
static Contact unregisterContact(const Contact &contact)
Removes the registration for a contact from the name server.
bool write(yarp::os::ConnectionWriter &writer) const override
Write this object to a network connection.
static int metaConnect(const std::string &src, const std::string &dest, ContactStyle style, int mode)
Contact unregisterName(const std::string &name) override
Disassociate contact information from a port name.
bool isBareMode() const override
Check if carrier excludes type information from payload.
virtual Carrier & getContent()
bool addOutput(const std::string &name) override
Add an output connection to the specified port.
bool open(SharedLibraryClassFactory< T > &factory)
Construct an instance using the specified factory.
static std::string collectParams(Contact &c)
StubCarrier(const char *name)
Property & addDict()
Places an empty key/value object in the bottle, at the end of the list.
A mini-server for network communication.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
bool setSelector(YarpPluginSelector &selector)
Use a selector to find a plugin or plugins.
static int getDefaultPortRange()
Under normal operation, YARP has a name server that manages a pool of (socket) ports starting at a po...
static MultiNameSpace & getNameSpace()
Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
std::string getName() const
Get the name associated with this factory.
Contact registerName(const std::string &name) override
Record contact information to tie to a port name.
void unsetEnvironment(const std::string &key)
Remove an environment variable.
static Contact registerName(const std::string &name)
Register a name with the name server.
yarp::os::Face * createFace() const override
Create new Face object that the carrier needs.
Carrier & getContent() override
PortReader & modifyReply(PortReader &reader) override
Modify reply payload data, if appropriate.
static bool getPortQos(const std::string &port, const std::string &unit, QosStyle &style, bool quiet)
static int disconnectInput(const std::string &src, const std::string &dest, bool silent=false)
Sends a disconnection command to the specified port.
static Contact queryName(const std::string &name)
Find out information about a registered name.
virtual bool disconnectPortToPortPersistently(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Disconnect two ports, removing any persistence.
void close() override
Close the carrier.
virtual bool open(const Route &route)=0
Start negotiating a carrier, using the given route (this should generally match the name of the sendi...
void useSystemClock()
Configure YARP to use system time (this is the default).
Value * getProperty(const std::string &name, const std::string &key) override
Get the value of a named key from a named port.
static std::string getDirectorySeparator()
Get an OS-appropriate directory separator (e.g.
std::string readString(bool *eof)
virtual bool disconnectPortFromTopic(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Stop publishing a port to a topic.
bool setLocalMode(bool flag)
static int poll(const std::string &target, bool silent=false)
Sends a 'describe yourself' message to a specified port, in order to receive information about the po...
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
virtual bool setProperty(const std::string &name, const std::string &key, const Value &value) override
Associate a key/value pair with a named port.
static void queryBypass(NameStore *store)
Redirect queries to another source.
void setAddress(const Contact &address)
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
bool write(ConnectionState &proto, SizedWriter &writer) override
Write a message.
bool supportReply() const override
This flag is used by YARP to determine whether the connection can carry RPC traffic,...
static std::string getPathSeparator()
Get an OS-appropriate path separator (e.g.
SharedLibraryClassFactory< Carrier > * factory
static Contact unregisterName(const std::string &name)
Removes the registration for a name from the name server.
static std::string expandFilename(const char *fname)
static YarpAutoInit yarp_auto_init
destructor is called on shutdown.
static void delaySystem(double seconds)
void setLibraryMethodName(const std::string &dll_name, const std::string &fn_name)
Set the name of the library to load and the method name to use as a factory.
virtual bool disconnectTopicFromPort(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Stop subscribing a port to a topic.
static bool getLocalMode()
Get current value of flag "localMode", see setLocalMode function.
yarpClockType getClockType()
ConnectionReader & modifyIncomingData(ConnectionReader &reader) override
Modify incoming payload data, if appropriate.
void setPluginName(const std::string &name)
Set the name of the plugin to load.
virtual bool asBool() const
Get boolean value.
bool isConnectionless() const override
Check if this carrier is connectionless (like udp, mcast) or connection based (like tcp).
virtual std::string asString() const
Get string value.
static bool connect(const std::string &src, const std::string &dest, const std::string &carrier="", bool quiet=true)
Request that an output port connect to an input port.
virtual bool announce(const std::string &name, int activity)=0
~YarpAutoInit()
Shut down the yarp library if it was automatically initialized.
static void yarpClockInit(yarp::os::yarpClockType clockType, Clock *custom=nullptr)
This function specifically initialize the clock In case clockType is one of the valid cases: YARP_CLO...
std::string toString() const override
Get name of carrier.
#define YARP_ENACT_DISCONNECT
bool canEscape() const override
Check if carrier can encode administrative messages, as opposed to just user data.
bool sendHeader(ConnectionState &proto) override
Write a header appropriate to the carrier to the connection, followed by any carrier-specific data.
virtual bool localOnly() const =0
Check if the NameSpace is only valid for the current process ("local").
virtual Connection & getConnection()=0
Get the connection whose protocol operations we are managing.
static void setMinimumPrintLevel(LogType level)
Set current minimum print level.
static bool needsLookup(const Contact &contact)
Carrier * create() const override
Factory method.
std::string getLibraryName() const
~ForwardingCarrier() override
void addInt32(std::int32_t x)
Places a 32-bit integer in the bottle, at the end of the list.
void setThreadPriority(int priority)
sets the communication thread priority level
NetInt32 encode(const std::string &str)
Convert a string into a vocabulary identifier.
static bool initialized()
Returns true if YARP has been fully initialized.
virtual bool connectPortToTopic(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Publish a port to a topic.
static void unsetEnvironment(const std::string &key)
Remove an environment variable.
void setReplyHandler(PortReader &reader) override
This sets a handler to deal with replies to the message.
bool checkHeader(const yarp::os::Bytes &header) override
Given the first 8 bytes received on a connection, decide if this is the right carrier type to use for...
static OutputProtocol * connect(const Contact &address)
Initiate a connection to an address.
#define YARP_ENACT_CONNECT
int getPacketPriorityAsTOS() const
returns the packet TOS value
int getReferenceCount() const
Get the current reference count of this factory.
static bool waitPort(const std::string &target, bool quiet=false)
Delays the system until a specified port is open.
static void finiMinimum()
Deinitialization, excluding plugins.
static int noteDud(const Contact &src)
static Contact detectNameServer(bool useDetectedServer, bool &scanNeeded, bool &serverUsed)
Scan for an available name server.
bool isValid() const
Check whether a valid instance has been created.
static void autoInitMinimum()
Basic system initialization, not including plugins.
virtual bool write(ConnectionWriter &writer) const =0
Write this object to a network connection.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
A simple abstraction for a block of bytes.
static Value * getProperty(const char *name, const char *key)
Look up the value associated with a particular key for a named entry registered with the nameserver.
void scan()
Find plugin configuration files, and run [plugin] sections through the select method.
static int enactConnection(const Contact &src, const Contact &dest, const ContactStyle &style, int mode, bool reversed)
static bool registerCarrier(const char *name, const char *dll)
Register a carrier to make available at runtime.
An abstract name space for ports.
Collect hints for finding a particular plugin.
virtual void close()=0
Negotiate an end to operations.
void addVocab(int x)
Places a vocabulary item in the bottle, at the end of the list.
bool sendAck(ConnectionState &proto) override
Send an acknowledgement, if needed for this carrier.
void useNetworkClock(const std::string &clock, const std::string &localPortName="")
Configure YARP to read time from a specified topic.
static bool setLocalMode(bool flag)
Chooses whether communication is process-local.
static bool isNetworkInitialized()
#define yCAssert(component, x)
virtual bool setTimeout(double timeout)=0
Set the timeout to be used for network operations.
virtual std::string getBootstrapCarrierName() const
Get the name of the carrier that should be used prior to handshaking, if a port is registered with th...
bool requireAck() const override
Check if carrier has flow control, requiring sent messages to be acknowledged by recipient.
static bool localNetworkAllocation()
Check where the name server in use expects processes to allocate their own network resources.
void setThreadPolicy(int policy)
sets the communication thread scheduling policy
An interface for reading from a network connection.
bool toFile(bool clean=false)
void setCarrierParams(const Property ¶ms) override
Configure carrier from port administrative commands.
static bool checkNetwork()
Check if the YARP Network is up and running.
bool acceptOutgoingData(const PortWriter &writer) override
Determine whether outgoing data should be accepted.
Contact unregisterContact(const Contact &contact) override
Disassociate contact information (should include a port name).
The basic state of a connection - route, streams in use, etc.
#define yCError(component,...)
virtual std::int32_t asInt32() const
Get 32-bit integer value.
void prepareDisconnect() override
Do cleanup and preparation for the coming disconnect, if necessary.
T & getContent()
Gives access to the created instance.
bool write(const PortWriter &writer, const PortWriter *callback=nullptr) const override
Write an object to the port.
bool connectionHasNameOfEndpoints() const override
When connections are made involving ports managed by this NameSpace do the ports involved end up know...
static std::string extractCarrierNameOnly(const std::string &carrier_name_with_params)
std::string getMethodName() const
SharedLibraryClass< Carrier > car
bool serverAllocatesPortNumbers() const override
Check if a central server is responsible for allocating port numbers, or if this should be left up to...
#define yCInfo(component,...)
An interface to the operating system, including Port based communication.
bool configureFromProperty(yarp::os::Property &options) override
#define yCDebug(component,...)
bool openFake(const std::string &name)
Start port without making it accessible from the network.
static void unlock()
Call post() on a global mutual-exclusion semaphore allocated by YARP.
bool configure(ConnectionState &proto) override
Give carrier a shot at looking at how the connection is set up.
bool activate(bool force=false)
virtual bool connectPortToPortPersistently(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Connect two ports with persistence.
bool expectExtraHeader(ConnectionState &proto) override
Receive any carrier-specific header.
StubCarrier(const char *dll_name, const char *fn_name)
static constexpr value_type preferred_separator
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
bool isLocal() const override
Check if carrier operates within a single process.
bool modifiesOutgoingData() const override
Check if this carrier modifies outgoing data through the Carrier::modifyOutgoingData method.
static std::string getNameServerName()
Get the name of the port associated with the nameserver (usually "/root", but this can be overwritten...
static bool isConnected(const std::string &src, const std::string &dest, bool quiet)
Check if a connection exists between two ports.
virtual Bottle * asList() const
Get list value.
bool fromFile(const char *ns=nullptr)
void setEnvironment(const std::string &key, const std::string &val)
Set or change an environment variable.
bool isClockInitialized()
Check if YARP clock is initialized.
virtual Contact detectNameServer(bool useDetectedServer, bool &scanNeeded, bool &serverUsed) override
Find a name server for this NameSpace, if applicable.
std::string getFnName() const
bool prepareSend(ConnectionState &proto) override
Perform any initialization needed before writing on a connection.
virtual int connect(const Contact &src, const Contact &dest, const ContactStyle &style, int mode, bool reversed)
Some carrier types may require special connection logic.
static bool setNameServerContact(Contact &nameServerContact)
Set explicitly the nameserver information.
#define yCTrace(component,...)
#define YARP_CONFIG_NAMESPACE_FILENAME
std::string toString() const override
Return a standard text representation of the content of the object.
static void setEnvironment(const std::string &key, const std::string &val)
Set or change an environment variable.
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
virtual bool write(SizedWriter &writer)=0
Write a message on the connection.
A single value (typically within a Bottle).
virtual bool checkNetwork()
Check if a name space is available.
static Contact getNameServerContact()
Get the contact information for the port associated with the nameserver (usually "/root",...
void useCustomClock(Clock *clock)
Configure YARP clients to use a custom clock source provided by the user.
Small helper class to help deal with legacy YARP configuration files.
static void setMinimumForwardLevel(LogType level)
Set current minimum forward level (it does nothing if forwarding is not enabled)
static int sendMessage(const std::string &port, yarp::os::PortWriter &writable, bool silent=false)
Just a reminder to sendMessage with temporary output parameter that will be discarded.
#define YARP_OS_LOG_COMPONENT(name, name_string)
The components from which ports and connections are built.
bool modifiesIncomingData() const override
Check if this carrier modifies incoming data through the Carrier::modifyIncomingData method.
The initial point-of-contact with a port.
int addRef()
Increment the reference count of this factory.
ForwardingCarrier(SharedLibraryClassFactory< Carrier > *factory, Carrier *owner)
#define YARP_ENACT_EXISTS
Minimal requirements for an efficient Writer.
A single-use class to shut down the yarp library if it was initialized automatically.
static std::string readString(bool *eof=nullptr)
Read a line of arbitrary length from standard input.
A class for storing options and configuration information.
bool canAccept() const override
Check if reading is implemented for this carrier.
virtual bool connectTopicToPort(const Contact &src, const Contact &dest, const ContactStyle &style)=0
Subscribe a port to a topic.
void setPacketPrioritybyTOS(int tos)
sets the packet priority given as TOS value
static int toInt(const std::string &x)
static bool disconnect(const std::string &src, const std::string &dest, bool quiet)
Request that an output port disconnect from an input port.
virtual bool isInt32() const
Checks if value is a 32-bit integer.
Contact getNameServerContact() const override
Get an address for a name server that manages the name space, if available.
#define yCFatal(component,...)
static bool exists(const std::string &port, bool quiet=true, bool checkVer=true)
Check for a port to be ready and responsive.