YARP
Yet Another Robot Platform
yarp::os::Network Class Reference

Utilities for manipulating the YARP network, including initialization and shutdown. More...

#include <yarp/os/Network.h>

+ Inheritance diagram for yarp::os::Network:

Detailed Description

Utilities for manipulating the YARP network, including initialization and shutdown.

Examples:
carrier/carrier_stub.cpp, dev/fake_motor.cpp, dev/file_grabber.cpp, dev/grabber_client.cpp, dev/motortest.cpp, framerate/main.cpp, os/buffered_port.cpp, os/database.cpp, os/image_process.cpp, os/image_process_module.cpp, os/image_source.cpp, os/make_count.cpp, os/portable_pair.cpp, os/ratethread.cpp, os/simple_receiver.cpp, os/simple_sender.cpp, os/summer.cpp, os/threads.cpp, os/view_count.cpp, port_power/ex0000_receiver.cpp, port_power/ex0001_sender.cpp, port_power/ex0002_connector.cpp, port_power/ex0100_receiver.cpp, port_power/ex0101_sender.cpp, port_power/ex0200_polling.cpp, port_power/ex0300_port_callback.cpp, port_power/ex0301_buffered_callback.cpp, port_power/ex0302_buffered_ext_callback.cpp, port_power/ex0400_expect_reply.cpp, port_power/ex0401_give_reply.cpp, port_power/ex0402_port_callback_reply.cpp, port_power/ex0403_bufferedport_callback_reply.cpp, port_power/ex0500_raw_target_receiver.cpp, port_power/ex0501_raw_target_sender.cpp, port_power/ex0502_raw_target_connector.cpp, port_power/ex0503_serial_target_receiver.cpp, port_power/ex0504_serial_target_sender.cpp, port_power/ex0505_compliant_target_receiver.cpp, port_power/ex0506_compliant_target_sender.cpp, port_power/ex0507_alternative_compliant_target_receiver.cpp, port_power/ex0508_alternative_compliant_target_sender.cpp, portaudio/sound_receiver.cpp, and portaudio/sound_sender_mic.cpp.

Definition at line 717 of file Network.h.

Public Member Functions

 Network ()
 Constructor. More...
 
 Network (yarp::os::yarpClockType clockType, yarp::os::Clock *custom=nullptr)
 Initialize the YARP network using the specified clock. More...
 
virtual ~Network ()
 Destructor. More...
 

Static Public Member Functions

static void init ()
 Initialization. More...
 
static void init (yarp::os::yarpClockType clockType, Clock *custom=nullptr)
 Initialization. More...
 
static void fini ()
 Deinitialization. More...
 
- Static Public Member Functions inherited from yarp::os::NetworkBase
static void initMinimum ()
 Basic system initialization, not including plugins. More...
 
static void initMinimum (yarp::os::yarpClockType clockType, yarp::os::Clock *custom=nullptr)
 Basic system initialization, not including plugins, The clock to be initialized can be specified. More...
 
static void autoInitMinimum ()
 Basic system initialization, not including plugins. More...
 
static void autoInitMinimum (yarp::os::yarpClockType clockType, yarp::os::Clock *custom=nullptr)
 Basic system initialization, not including plugins. More...
 
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_CLOCK_SYSTEM, YARP_CLOCK_NETWORK, YARP_CLOCK_CUSTOM (see yarp::os::Time for more), the corresponding clock will be initialized. More...
 
static void finiMinimum ()
 Deinitialization, excluding plugins. More...
 
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. More...
 
static bool connect (const char *src, const char *dest, const char *carrier, bool quiet=true)
 
static bool connect (const std::string &src, const std::string &dest, const ContactStyle &style)
 Request that an output port connect to an input port. More...
 
static bool disconnect (const std::string &src, const std::string &dest, bool quiet=true)
 Request that an output port disconnect from an input port. More...
 
static bool disconnect (const std::string &src, const std::string &dest, const ContactStyle &style)
 Request that an output port disconnect from an input port. More...
 
static bool isConnected (const std::string &src, const std::string &dest, bool quiet=true)
 Check if a connection exists between two ports. More...
 
static bool isConnected (const std::string &src, const std::string &dest, const ContactStyle &style)
 Check if a connection exists between two ports. More...
 
static bool exists (const std::string &port, bool quiet=true, bool checkVer=true)
 Check for a port to be ready and responsive. More...
 
static bool exists (const std::string &port, const ContactStyle &style, bool checkVer=true)
 Check for a port to be ready and responsive. More...
 
static bool sync (const std::string &port, bool quiet=true)
 Wait for a port to be ready and responsive. More...
 
static void assertion (bool shouldBeTrue)
 An assertion. More...
 
static Contact queryName (const std::string &name)
 Find out information about a registered name. More...
 
static Contact registerName (const std::string &name)
 Register a name with the name server. More...
 
static Contact registerContact (const Contact &contact)
 Register contact information with the name server. More...
 
static Contact unregisterName (const std::string &name)
 Removes the registration for a name from the name server. More...
 
static Contact unregisterContact (const Contact &contact)
 Removes the registration for a contact from the name server. More...
 
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. More...
 
static ValuegetProperty (const char *name, const char *key)
 Look up the value associated with a particular key for a named entry registered with the nameserver. More...
 
static std::string getNameServerName ()
 Get the name of the port associated with the nameserver (usually "/root", but this can be overwritten by the "yarp namespace" command). More...
 
static Contact getNameServerContact ()
 Get the contact information for the port associated with the nameserver (usually "/root", but this can be overwritten by the "yarp namespace" command). More...
 
static bool setNameServerName (const std::string &name)
 Set the name of the port associated with the nameserver (usually "/root", but this can be overwritten by the "yarp namespace" command). More...
 
static bool setLocalMode (bool flag)
 Chooses whether communication is process-local. More...
 
static bool getLocalMode ()
 Get current value of flag "localMode", see setLocalMode function. More...
 
static std::string readString (bool *eof=nullptr)
 Read a line of arbitrary length from standard input. More...
 
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. More...
 
static bool write (const Contact &contact, PortWriter &cmd, PortReader &reply, const ContactStyle &style)
 Variant write method with options bundled into a yarp::os::ContactStyle (there was getting to be too many of them). More...
 
static bool writeToNameServer (PortWriter &cmd, PortReader &reply, const ContactStyle &style)
 Variant write method specialized to name server. More...
 
static bool write (const std::string &port_name, PortWriter &cmd, PortReader &reply)
 Variant write method with port name specified directly. More...
 
static bool checkNetwork ()
 Check if the YARP Network is up and running. More...
 
static bool checkNetwork (double timeout)
 Check if a name server is running and responding. More...
 
static bool initialized ()
 Returns true if YARP has been fully initialized. More...
 
static void setVerbosity (int verbosity)
 Set level of verbosity of YARP messages. More...
 
static void queryBypass (NameStore *store)
 Redirect queries to another source. More...
 
static NameStoregetQueryBypass ()
 
static std::string getEnvironment (const char *key, bool *found=nullptr)
 Read a variable from the environment. More...
 
static void setEnvironment (const std::string &key, const std::string &val)
 Set or change an environment variable. More...
 
static void unsetEnvironment (const std::string &key)
 Remove an environment variable. More...
 
static std::string getDirectorySeparator ()
 Get an OS-appropriate directory separator (e.g. More...
 
static std::string getPathSeparator ()
 Get an OS-appropriate path separator (e.g. More...
 
static bool registerCarrier (const char *name, const char *dll)
 Register a carrier to make available at runtime. More...
 
static void lock ()
 Call wait() on a global mutual-exclusion semaphore allocated by YARP. More...
 
static void unlock ()
 Call post() on a global mutual-exclusion semaphore allocated by YARP. More...
 
static bool localNetworkAllocation ()
 Check where the name server in use expects processes to allocate their own network resources. More...
 
static Contact detectNameServer (bool useDetectedServer, bool &scanNeeded, bool &serverUsed)
 Scan for an available name server. More...
 
static bool setNameServerContact (Contact &nameServerContact)
 Set explicitly the nameserver information. More...
 
static std::string getConfigFile (const char *fname)
 Search for a configuration file in YARP's standard config file path. More...
 
static int getDefaultPortRange ()
 Under normal operation, YARP has a name server that manages a pool of (socket) ports starting at a point specified by the YARP_PORT_RANGE environment variable (or 10000 if that is not set). More...
 
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. More...
 
static bool setConnectionQos (const std::string &src, const std::string &dest, const QosStyle &style, bool quiet=true)
 Adjust the Qos preferences of a connection. More...
 
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. More...
 
static bool isValidPortName (const std::string &portName)
 Checks that the port has a valid name. More...
 
static bool waitConnection (const std::string &source, const std::string &destination, bool quiet=false)
 Delays the system until a specified connection is established. More...
 
static bool waitPort (const std::string &target, bool quiet=false)
 Delays the system until a specified port is open. More...
 
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. More...
 
static int sendMessage (const std::string &port, yarp::os::PortWriter &writable, std::string &output, bool quiet)
 Sends a message to the specified port. More...
 
static int disconnectInput (const std::string &src, const std::string &dest, bool silent=false)
 Sends a disconnection command to the specified port. More...
 
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 port and its connections. More...
 

Constructor & Destructor Documentation

◆ Network() [1/2]

yarp::os::Network::Network ( )

Constructor.

Configures process to use the YARP network. Can be more convenient to use than calling Network::init() directly, since it will clean things up with a call to Network::fini() automatically.

◆ Network() [2/2]

yarp::os::Network::Network ( yarp::os::yarpClockType  clockType,
yarp::os::Clock custom = nullptr 
)

Initialize the YARP network using the specified clock.

This function will take precedence with respect to the environment variable YARP_CLOCK because it is explixitly required by the user.

Calling this function with UNDEFINED_CLOCK is equivalent to use the classic yarp::Network() method and the environment variable will be used.

In case CUSTOM_CLOCK is used, the Clock pointer must point to a valid Clock object already initialized.

◆ ~Network()

virtual yarp::os::Network::~Network ( )
virtual

Destructor.

Disconnects from the YARP network.

Member Function Documentation

◆ fini()

static void yarp::os::Network::fini ( )
static

Deinitialization.

On some operating systems, there are certain shut-down tasks that need to be performed, and this method does them. It is a good idea to call Network::init near the start of your program, and to call this method towards the end.

Examples:
dev/motortest.cpp.

◆ init() [1/2]

static void yarp::os::Network::init ( )
static

Initialization.

On some operating systems, there are certain start-up tasks that need to be performed, and this method does them. It is a good idea to call this method near the start of your program, and to call Network::fini towards the end.

◆ init() [2/2]

static void yarp::os::Network::init ( yarp::os::yarpClockType  clockType,
Clock custom = nullptr 
)
static

Initialization.

Same as init(), but let the user configure which clock shall be used right from the initialization phase.


The documentation for this class was generated from the following file: