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

#include <yarp/os/RosNameSpace.h>

+ Inheritance diagram for yarp::os::RosNameSpace:

Detailed Description

Definition at line 23 of file RosNameSpace.h.

Public Member Functions

 RosNameSpace (const Contact &contact)
 
virtual ~RosNameSpace ()
 
virtual Contact getNameServerContact () const override
 Get an address for a name server that manages the name space, if available. More...
 
virtual Contact queryName (const std::string &name) override
 Map from port name to contact information. More...
 
virtual Contact registerName (const std::string &name) override
 Record contact information to tie to a port name. More...
 
virtual Contact registerContact (const Contact &contact) override
 Record contact information (should include a port name). More...
 
virtual Contact unregisterName (const std::string &name) override
 Disassociate contact information from a port name. More...
 
virtual Contact unregisterContact (const Contact &contact) override
 Disassociate contact information (should include a port name). More...
 
virtual Contact registerAdvanced (const Contact &contact, NameStore *store) override
 Record contact information, with access to the contact information of other ports for cross-referencing. More...
 
virtual Contact unregisterAdvanced (const std::string &name, NameStore *store) override
 Remove contact information, with access to the contact information of other ports for cross-referencing. More...
 
virtual bool setProperty (const std::string &name, const std::string &key, const Value &value) override
 Associate a key/value pair with a named port. More...
 
virtual ValuegetProperty (const std::string &name, const std::string &key) override
 Get the value of a named key from a named port. More...
 
virtual bool connectPortToTopic (const Contact &src, const Contact &dest, ContactStyle style) override
 Publish a port to a topic. More...
 
virtual bool connectTopicToPort (const Contact &src, const Contact &dest, ContactStyle style) override
 Subscribe a port to a topic. More...
 
virtual bool disconnectPortFromTopic (const Contact &src, const Contact &dest, ContactStyle style) override
 Stop publishing a port to a topic. More...
 
virtual bool disconnectTopicFromPort (const Contact &src, const Contact &dest, ContactStyle style) override
 Stop subscribing a port to a topic. More...
 
virtual bool connectPortToPortPersistently (const Contact &src, const Contact &dest, ContactStyle style) override
 Connect two ports with persistence. More...
 
virtual bool disconnectPortToPortPersistently (const Contact &src, const Contact &dest, ContactStyle style) override
 Disconnect two ports, removing any persistence. More...
 
virtual bool connectTopic (Bottle &cmd, bool srcIsTopic, const Contact &src, const Contact &dest, ContactStyle style, bool activeRegistration)
 
virtual bool localOnly () const override
 Check if the NameSpace is only valid for the current process ("local"). More...
 
virtual bool usesCentralServer () const override
 Check if a central server is involved in managing the NameSpace. More...
 
virtual bool serverAllocatesPortNumbers () const override
 Check if a central server is responsible for allocating port numbers, or if this should be left up to the operating system. More...
 
virtual bool connectionHasNameOfEndpoints () const override
 When connections are made involving ports managed by this NameSpace do the ports involved end up knowing the names of their counterparties? More...
 
virtual Contact detectNameServer (bool useDetectedServer, bool &scanNeeded, bool &serverUsed) override
 Find a name server for this NameSpace, if applicable. More...
 
virtual bool writeToNameServer (PortWriter &cmd, PortReader &reply, const ContactStyle &style) override
 Write a message to a name server for this NameSpace, if applicable. More...
 
virtual void run () override
 Main body of the new thread. More...
 
- Public Member Functions inherited from yarp::os::NameSpace
virtual ~NameSpace ()
 Destructor. More...
 
virtual bool checkNetwork ()
 Check if a name space is available. More...
 
virtual bool checkNetwork (double timeout)
 Check if a name space is available, with a timeout on any network operations needed. More...
 
virtual std::string getNameServerName () const
 Get the port name of a name server that manages the name space, if available. More...
 
- Public Member Functions inherited from yarp::os::Thread
 Thread ()
 Constructor. More...
 
virtual ~Thread ()
 Destructor. More...
 
virtual void onStop ()
 Call-back, called while halting the thread (before join). More...
 
bool start ()
 Start the new thread running. More...
 
bool stop ()
 Stop the thread. More...
 
virtual void beforeStart ()
 Called just before a new thread starts. More...
 
virtual void afterStart (bool success)
 Called just after a new thread starts (or fails to start), this is executed by the same thread that calls start(). More...
 
virtual bool threadInit ()
 Initialization method. More...
 
virtual void threadRelease ()
 Release method. More...
 
bool isStopping ()
 Returns true if the thread is stopping (Thread::stop has been called). More...
 
bool isRunning ()
 Returns true if the thread is running (Thread::start has been called successfully and the thread has not stopped). More...
 
long int getKey ()
 Get a unique identifier for the thread. More...
 
int setPriority (int priority, int policy=-1)
 Set the priority and scheduling policy of the thread, if the OS supports that. More...
 
int getPriority ()
 Query the current priority of the thread, if the OS supports that. More...
 
int getPolicy ()
 Query the current scheduling policy of the thread, if the OS supports that. More...
 
bool join (double seconds=-1)
 The function returns when the thread execution has completed. More...
 
void setOptions (int stackSize=0)
 Set the stack size for the new thread. More...
 

Static Public Member Functions

static std::string toRosName (const std::string &name)
 Possible ROS names are a subset of YARP names. More...
 
static std::string fromRosName (const std::string &name)
 
static std::string toRosNodeName (const std::string &name)
 
static std::string fromRosNodeName (const std::string &name)
 
static Contact rosify (const Contact &contact)
 
- Static Public Member Functions inherited from yarp::os::Thread
static int getCount ()
 Check how many threads are running. More...
 
static long int getKeyOfCaller ()
 Get a unique identifier for the calling thread. More...
 
static void yield ()
 Reschedule the execution of current thread, allowing other threads to run. More...
 
static void setDefaultStackSize (int stackSize)
 Set the default stack size for all threads created after this point. More...
 

Private Attributes

Contact contact
 
Bottle pending
 
Mutex mutex
 

Constructor & Destructor Documentation

◆ RosNameSpace()

RosNameSpace::RosNameSpace ( const Contact contact)

Definition at line 28 of file RosNameSpace.cpp.

◆ ~RosNameSpace()

RosNameSpace::~RosNameSpace ( )
virtual

Definition at line 32 of file RosNameSpace.cpp.

Member Function Documentation

◆ connectionHasNameOfEndpoints()

bool RosNameSpace::connectionHasNameOfEndpoints ( ) const
overridevirtual

When connections are made involving ports managed by this NameSpace do the ports involved end up knowing the names of their counterparties?

Implements yarp::os::NameSpace.

Definition at line 486 of file RosNameSpace.cpp.

◆ connectPortToPortPersistently()

bool RosNameSpace::connectPortToPortPersistently ( const Contact src,
const Contact dest,
ContactStyle  style 
)
overridevirtual

Connect two ports with persistence.

Implements yarp::os::NameSpace.

Definition at line 408 of file RosNameSpace.cpp.

◆ connectPortToTopic()

bool RosNameSpace::connectPortToTopic ( const Contact src,
const Contact dest,
ContactStyle  style 
)
overridevirtual

Publish a port to a topic.

Implements yarp::os::NameSpace.

Definition at line 360 of file RosNameSpace.cpp.

◆ connectTopic()

bool RosNameSpace::connectTopic ( Bottle cmd,
bool  srcIsTopic,
const Contact src,
const Contact dest,
ContactStyle  style,
bool  activeRegistration 
)
virtual

Definition at line 426 of file RosNameSpace.cpp.

◆ connectTopicToPort()

bool RosNameSpace::connectTopicToPort ( const Contact src,
const Contact dest,
ContactStyle  style 
)
overridevirtual

Subscribe a port to a topic.

Implements yarp::os::NameSpace.

Definition at line 373 of file RosNameSpace.cpp.

◆ detectNameServer()

Contact RosNameSpace::detectNameServer ( bool  useDetectedServer,
bool &  scanNeeded,
bool &  serverUsed 
)
overridevirtual

Find a name server for this NameSpace, if applicable.

Parameters
useDetectedServeruse any server found for future queries.
scanNeededset to true if a search was needed, rather than finding a name server based on cached hints.
serverUsedset to true if a server was found and marked for use in future queries.

Implements yarp::os::NameSpace.

Definition at line 490 of file RosNameSpace.cpp.

◆ disconnectPortFromTopic()

bool RosNameSpace::disconnectPortFromTopic ( const Contact src,
const Contact dest,
ContactStyle  style 
)
overridevirtual

Stop publishing a port to a topic.

Implements yarp::os::NameSpace.

Definition at line 386 of file RosNameSpace.cpp.

◆ disconnectPortToPortPersistently()

bool RosNameSpace::disconnectPortToPortPersistently ( const Contact src,
const Contact dest,
ContactStyle  style 
)
overridevirtual

Disconnect two ports, removing any persistence.

Implements yarp::os::NameSpace.

Definition at line 417 of file RosNameSpace.cpp.

◆ disconnectTopicFromPort()

bool RosNameSpace::disconnectTopicFromPort ( const Contact src,
const Contact dest,
ContactStyle  style 
)
overridevirtual

Stop subscribing a port to a topic.

Implements yarp::os::NameSpace.

Definition at line 397 of file RosNameSpace.cpp.

◆ fromRosName()

std::string RosNameSpace::fromRosName ( const std::string &  name)
static

Definition at line 609 of file RosNameSpace.cpp.

◆ fromRosNodeName()

std::string RosNameSpace::fromRosNodeName ( const std::string &  name)
static

Definition at line 635 of file RosNameSpace.cpp.

◆ getNameServerContact()

Contact RosNameSpace::getNameServerContact ( ) const
overridevirtual

Get an address for a name server that manages the name space, if available.

Implements yarp::os::NameSpace.

Definition at line 36 of file RosNameSpace.cpp.

◆ getProperty()

Value * RosNameSpace::getProperty ( const std::string &  name,
const std::string &  key 
)
overridevirtual

Get the value of a named key from a named port.

Returns
nullptr if no value was set for the named key.

Implements yarp::os::NameSpace.

Definition at line 353 of file RosNameSpace.cpp.

◆ localOnly()

bool RosNameSpace::localOnly ( ) const
overridevirtual

Check if the NameSpace is only valid for the current process ("local").

Implements yarp::os::NameSpace.

Definition at line 474 of file RosNameSpace.cpp.

◆ queryName()

Contact RosNameSpace::queryName ( const std::string &  name)
overridevirtual

Map from port name to contact information.

Implements yarp::os::NameSpace.

Definition at line 40 of file RosNameSpace.cpp.

◆ registerAdvanced()

Contact RosNameSpace::registerAdvanced ( const Contact contact,
NameStore store 
)
overridevirtual

Record contact information, with access to the contact information of other ports for cross-referencing.

Parameters
contactthe contact information to record
storean interface to port information as presented via the YARP client API (as opposed to what a single NameSpace would have access to).

Reimplemented from yarp::os::NameSpace.

Definition at line 94 of file RosNameSpace.cpp.

◆ registerContact()

Contact RosNameSpace::registerContact ( const Contact contact)
overridevirtual

Record contact information (should include a port name).

Implements yarp::os::NameSpace.

Definition at line 90 of file RosNameSpace.cpp.

◆ registerName()

Contact RosNameSpace::registerName ( const std::string &  name)
overridevirtual

Record contact information to tie to a port name.

Implements yarp::os::NameSpace.

Definition at line 81 of file RosNameSpace.cpp.

◆ rosify()

Contact RosNameSpace::rosify ( const Contact contact)
static

Definition at line 639 of file RosNameSpace.cpp.

◆ run()

void RosNameSpace::run ( )
overridevirtual

Main body of the new thread.

Override this method to do what you want. After Thread::start is called, this method will start running in a separate thread. It is important that this method either keeps checking Thread::isStopping to see if it should stop, or you override the Thread::onStop method to interact with it in some way to shut the new thread down. There is no really reliable, portable way to stop a thread cleanly unless that thread cooperates.

Implements yarp::os::Thread.

Definition at line 651 of file RosNameSpace.cpp.

◆ serverAllocatesPortNumbers()

bool RosNameSpace::serverAllocatesPortNumbers ( ) const
overridevirtual

Check if a central server is responsible for allocating port numbers, or if this should be left up to the operating system.

Implements yarp::os::NameSpace.

Definition at line 482 of file RosNameSpace.cpp.

◆ setProperty()

bool RosNameSpace::setProperty ( const std::string &  name,
const std::string &  key,
const Value value 
)
overridevirtual

Associate a key/value pair with a named port.

Implements yarp::os::NameSpace.

Definition at line 344 of file RosNameSpace.cpp.

◆ toRosName()

std::string RosNameSpace::toRosName ( const std::string &  name)
static

Possible ROS names are a subset of YARP names.

For nodes, in practice there isn't much restriction, except ":" is definitely ruled out. Since plenty of valid YARP ports have a ":" in them, we need to quote this.

Definition at line 596 of file RosNameSpace.cpp.

◆ toRosNodeName()

std::string RosNameSpace::toRosNodeName ( const std::string &  name)
static

Definition at line 631 of file RosNameSpace.cpp.

◆ unregisterAdvanced()

Contact RosNameSpace::unregisterAdvanced ( const std::string &  name,
NameStore store 
)
overridevirtual

Remove contact information, with access to the contact information of other ports for cross-referencing.

Reimplemented from yarp::os::NameSpace.

Definition at line 245 of file RosNameSpace.cpp.

◆ unregisterContact()

Contact RosNameSpace::unregisterContact ( const Contact contact)
overridevirtual

Disassociate contact information (should include a port name).

Implements yarp::os::NameSpace.

Definition at line 329 of file RosNameSpace.cpp.

◆ unregisterName()

Contact RosNameSpace::unregisterName ( const std::string &  name)
overridevirtual

Disassociate contact information from a port name.

Implements yarp::os::NameSpace.

Definition at line 241 of file RosNameSpace.cpp.

◆ usesCentralServer()

bool RosNameSpace::usesCentralServer ( ) const
overridevirtual

Check if a central server is involved in managing the NameSpace.

Implements yarp::os::NameSpace.

Definition at line 478 of file RosNameSpace.cpp.

◆ writeToNameServer()

bool RosNameSpace::writeToNameServer ( PortWriter cmd,
PortReader reply,
const ContactStyle style 
)
overridevirtual

Write a message to a name server for this NameSpace, if applicable.

Messages are name-server-specific.

Implements yarp::os::NameSpace.

Definition at line 518 of file RosNameSpace.cpp.

Member Data Documentation

◆ contact

Contact yarp::os::RosNameSpace::contact
private

Definition at line 102 of file RosNameSpace.h.

◆ mutex

Mutex yarp::os::RosNameSpace::mutex
private

Definition at line 104 of file RosNameSpace.h.

◆ pending

Bottle yarp::os::RosNameSpace::pending
private

Definition at line 103 of file RosNameSpace.h.


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