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

#include <yarp/os/RosNameSpace.h>

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

Public Member Functions

 RosNameSpace (const Contact &contact)
 
virtual ~RosNameSpace ()
 
virtual Contact getNameServerContact () const YARP_OVERRIDE
 Get an address for a name server that manages the name space, if available. More...
 
virtual Contact queryName (const ConstString &name) YARP_OVERRIDE
 Map from port name to contact information. More...
 
virtual Contact registerName (const ConstString &name) YARP_OVERRIDE
 Record contact information to tie to a port name. More...
 
virtual Contact registerContact (const Contact &contact) YARP_OVERRIDE
 Record contact information (should include a port name). More...
 
virtual Contact unregisterName (const ConstString &name) YARP_OVERRIDE
 Disassociate contact information from a port name. More...
 
virtual Contact unregisterContact (const Contact &contact) YARP_OVERRIDE
 Disassociate contact information (should include a port name). More...
 
virtual Contact registerAdvanced (const Contact &contact, NameStore *store) YARP_OVERRIDE
 Record contact information, with access to the contact information of other ports for cross-referencing. More...
 
virtual Contact unregisterAdvanced (const ConstString &name, NameStore *store) YARP_OVERRIDE
 Remove contact information, with access to the contact information of other ports for cross-referencing. More...
 
virtual bool setProperty (const ConstString &name, const ConstString &key, const Value &value) YARP_OVERRIDE
 Associate a key/value pair with a named port. More...
 
virtual ValuegetProperty (const ConstString &name, const ConstString &key) YARP_OVERRIDE
 Get the value of a named key from a named port. More...
 
virtual bool connectPortToTopic (const Contact &src, const Contact &dest, ContactStyle style) YARP_OVERRIDE
 Publish a port to a topic. More...
 
virtual bool connectTopicToPort (const Contact &src, const Contact &dest, ContactStyle style) YARP_OVERRIDE
 Subscribe a port to a topic. More...
 
virtual bool disconnectPortFromTopic (const Contact &src, const Contact &dest, ContactStyle style) YARP_OVERRIDE
 Stop publishing a port to a topic. More...
 
virtual bool disconnectTopicFromPort (const Contact &src, const Contact &dest, ContactStyle style) YARP_OVERRIDE
 Stop subscribing a port to a topic. More...
 
virtual bool connectPortToPortPersistently (const Contact &src, const Contact &dest, ContactStyle style) YARP_OVERRIDE
 Connect two ports with persistence. More...
 
virtual bool disconnectPortToPortPersistently (const Contact &src, const Contact &dest, ContactStyle style) YARP_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 YARP_OVERRIDE
 Check if the NameSpace is only valid for the current process ("local"). More...
 
virtual bool usesCentralServer () const YARP_OVERRIDE
 Check if a central server is involved in managing the NameSpace. More...
 
virtual bool serverAllocatesPortNumbers () const YARP_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 YARP_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) YARP_OVERRIDE
 Find a name server for this NameSpace, if applicable. More...
 
virtual bool writeToNameServer (PortWriter &cmd, PortReader &reply, const ContactStyle &style) YARP_OVERRIDE
 Write a message to a name server for this NameSpace, if applicable. More...
 
virtual void run () YARP_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 name space is available. More...
 
virtual bool checkNetwork (double timeout)
 Check if name space is available, with a timeout on any network operations needed. More...
 
virtual ConstString 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...
 
void setOptions (int stackSize=0)
 Set the stack size for the new thread. 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...
 

Static Public Member Functions

static ConstString toRosName (const ConstString &name)
 Possible ROS names are a subset of YARP names. More...
 
static ConstString fromRosName (const ConstString &name)
 
static ConstString toRosNodeName (const ConstString &name)
 
static ConstString fromRosNodeName (const ConstString &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 setDefaultStackSize (int stackSize)
 Set the default stack size for all threads created after this point. More...
 
static void yield ()
 Reschedule the execution of current thread, allowing other threads to run. More...
 

Private Attributes

Contact contact
 
Bottle pending
 
Semaphore mutex
 

Detailed Description

Definition at line 24 of file RosNameSpace.h.

Constructor & Destructor Documentation

◆ RosNameSpace()

RosNameSpace::RosNameSpace ( const Contact contact)

Definition at line 25 of file RosNameSpace.cpp.

◆ ~RosNameSpace()

RosNameSpace::~RosNameSpace ( )
virtual

Definition at line 29 of file RosNameSpace.cpp.

Member Function Documentation

◆ connectionHasNameOfEndpoints()

bool RosNameSpace::connectionHasNameOfEndpoints ( ) const
virtual

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 471 of file RosNameSpace.cpp.

◆ connectPortToPortPersistently()

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

Connect two ports with persistence.

Implements yarp::os::NameSpace.

Definition at line 399 of file RosNameSpace.cpp.

◆ connectPortToTopic()

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

Publish a port to a topic.

Implements yarp::os::NameSpace.

Definition at line 351 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 411 of file RosNameSpace.cpp.

◆ connectTopicToPort()

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

Subscribe a port to a topic.

Implements yarp::os::NameSpace.

Definition at line 364 of file RosNameSpace.cpp.

◆ detectNameServer()

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

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 475 of file RosNameSpace.cpp.

◆ disconnectPortFromTopic()

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

Stop publishing a port to a topic.

Implements yarp::os::NameSpace.

Definition at line 377 of file RosNameSpace.cpp.

◆ disconnectPortToPortPersistently()

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

Disconnect two ports, removing any persistence.

Implements yarp::os::NameSpace.

Definition at line 405 of file RosNameSpace.cpp.

◆ disconnectTopicFromPort()

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

Stop subscribing a port to a topic.

Implements yarp::os::NameSpace.

Definition at line 388 of file RosNameSpace.cpp.

◆ fromRosName()

ConstString RosNameSpace::fromRosName ( const ConstString name)
static

Definition at line 602 of file RosNameSpace.cpp.

◆ fromRosNodeName()

ConstString RosNameSpace::fromRosNodeName ( const ConstString name)
static

Definition at line 628 of file RosNameSpace.cpp.

◆ getNameServerContact()

Contact RosNameSpace::getNameServerContact ( ) const
virtual

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

Implements yarp::os::NameSpace.

Definition at line 33 of file RosNameSpace.cpp.

◆ getProperty()

Value * RosNameSpace::getProperty ( const ConstString name,
const ConstString key 
)
virtual

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

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

Implements yarp::os::NameSpace.

Definition at line 346 of file RosNameSpace.cpp.

◆ localOnly()

bool RosNameSpace::localOnly ( ) const
virtual

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

Implements yarp::os::NameSpace.

Definition at line 459 of file RosNameSpace.cpp.

◆ queryName()

Contact RosNameSpace::queryName ( const ConstString name)
virtual

Map from port name to contact information.

Implements yarp::os::NameSpace.

Definition at line 37 of file RosNameSpace.cpp.

◆ registerAdvanced()

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

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 90 of file RosNameSpace.cpp.

◆ registerContact()

Contact RosNameSpace::registerContact ( const Contact contact)
virtual

Record contact information (should include a port name).

Implements yarp::os::NameSpace.

Definition at line 86 of file RosNameSpace.cpp.

◆ registerName()

Contact RosNameSpace::registerName ( const ConstString name)
virtual

Record contact information to tie to a port name.

Implements yarp::os::NameSpace.

Definition at line 78 of file RosNameSpace.cpp.

◆ rosify()

Contact RosNameSpace::rosify ( const Contact contact)
static

Definition at line 632 of file RosNameSpace.cpp.

◆ run()

void RosNameSpace::run ( )
virtual

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 644 of file RosNameSpace.cpp.

◆ serverAllocatesPortNumbers()

bool RosNameSpace::serverAllocatesPortNumbers ( ) const
virtual

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 467 of file RosNameSpace.cpp.

◆ setProperty()

bool RosNameSpace::setProperty ( const ConstString name,
const ConstString key,
const Value value 
)
virtual

Associate a key/value pair with a named port.

Implements yarp::os::NameSpace.

Definition at line 340 of file RosNameSpace.cpp.

◆ toRosName()

ConstString RosNameSpace::toRosName ( const ConstString 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 589 of file RosNameSpace.cpp.

◆ toRosNodeName()

ConstString RosNameSpace::toRosNodeName ( const ConstString name)
static

Definition at line 624 of file RosNameSpace.cpp.

◆ unregisterAdvanced()

Contact RosNameSpace::unregisterAdvanced ( const ConstString name,
NameStore store 
)
virtual

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

Reimplemented from yarp::os::NameSpace.

Definition at line 241 of file RosNameSpace.cpp.

◆ unregisterContact()

Contact RosNameSpace::unregisterContact ( const Contact contact)
virtual

Disassociate contact information (should include a port name).

Implements yarp::os::NameSpace.

Definition at line 325 of file RosNameSpace.cpp.

◆ unregisterName()

Contact RosNameSpace::unregisterName ( const ConstString name)
virtual

Disassociate contact information from a port name.

Implements yarp::os::NameSpace.

Definition at line 237 of file RosNameSpace.cpp.

◆ usesCentralServer()

bool RosNameSpace::usesCentralServer ( ) const
virtual

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

Implements yarp::os::NameSpace.

Definition at line 463 of file RosNameSpace.cpp.

◆ writeToNameServer()

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

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

Messages are name-server-specific.

Implements yarp::os::NameSpace.

Definition at line 502 of file RosNameSpace.cpp.

Member Data Documentation

◆ contact

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

Definition at line 102 of file RosNameSpace.h.

◆ mutex

Semaphore 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: