YARP  2.3.68+220-20170323.2+git4955ef0
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
 Get an address for a name server that manages the name space, if available. More...
 
virtual Contact queryName (const ConstString &name)
 Map from port name to contact information. More...
 
virtual Contact registerName (const ConstString &name)
 Record contact information to tie to a port name. More...
 
virtual Contact registerContact (const Contact &contact)
 Record contact information (should include a port name). More...
 
virtual Contact unregisterName (const ConstString &name)
 Disassociate contact information from a port name. More...
 
virtual Contact unregisterContact (const Contact &contact)
 Disassociate contact information (should include a port name). More...
 
virtual Contact registerAdvanced (const Contact &contact, NameStore *store)
 Record contact information, with access to the contact information of other ports for cross-referencing. More...
 
virtual Contact unregisterAdvanced (const ConstString &name, NameStore *store)
 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)
 Associate a key/value pair with a named port. More...
 
virtual ValuegetProperty (const ConstString &name, const ConstString &key)
 Get the value of a named key from a named port. More...
 
virtual bool connectPortToTopic (const Contact &src, const Contact &dest, ContactStyle style)
 Publish a port to a topic. More...
 
virtual bool connectTopicToPort (const Contact &src, const Contact &dest, ContactStyle style)
 Subscribe a port to a topic. More...
 
virtual bool disconnectPortFromTopic (const Contact &src, const Contact &dest, ContactStyle style)
 Stop publishing a port to a topic. More...
 
virtual bool disconnectTopicFromPort (const Contact &src, const Contact &dest, ContactStyle style)
 Stop subscribing a port to a topic. More...
 
virtual bool connectPortToPortPersistently (const Contact &src, const Contact &dest, ContactStyle style)
 Connect two ports with persistence. More...
 
virtual bool disconnectPortToPortPersistently (const Contact &src, const Contact &dest, ContactStyle style)
 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
 Check if the NameSpace is only valid for the current process ("local"). More...
 
virtual bool usesCentralServer () const
 Check if a central server is involved in managing the NameSpace. More...
 
virtual bool serverAllocatesPortNumbers () const
 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
 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)
 Find a name server for this NameSpace, if applicable. More...
 
virtual bool writeToNameServer (PortWriter &cmd, PortReader &reply, const ContactStyle &style)
 Write a message to a name server for this NameSpace, if applicable. More...
 
virtual void run ()
 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 27 of file RosNameSpace.cpp.

◆ ~RosNameSpace()

RosNameSpace::~RosNameSpace ( )
virtual

Definition at line 31 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 473 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 401 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 353 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 413 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 366 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 477 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 379 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 407 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 390 of file RosNameSpace.cpp.

◆ fromRosName()

ConstString RosNameSpace::fromRosName ( const ConstString name)
static

Definition at line 604 of file RosNameSpace.cpp.

◆ fromRosNodeName()

ConstString RosNameSpace::fromRosNodeName ( const ConstString name)
static

Definition at line 630 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 35 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 348 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 461 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 39 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 92 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 88 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 80 of file RosNameSpace.cpp.

◆ rosify()

Contact RosNameSpace::rosify ( const Contact contact)
static

Definition at line 634 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 647 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 469 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 342 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 591 of file RosNameSpace.cpp.

◆ toRosNodeName()

ConstString RosNameSpace::toRosNodeName ( const ConstString name)
static

Definition at line 626 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 243 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 327 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 239 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 465 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 504 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: