YARP
Yet Another Robot Platform
yarp::os::impl::PortCoreUnit Class Reference

This manages a single threaded resource related to a single input or output connection. More...

#include <yarp/os/impl/PortCoreUnit.h>

+ Inheritance diagram for yarp::os::impl::PortCoreUnit:

Public Member Functions

 PortCoreUnit (PortCore &owner, int index)
 Constructor. More...
 
virtual ~PortCoreUnit ()
 Destructor. More...
 
virtual bool isInput ()
 
virtual bool isOutput ()
 
virtual bool isFinished ()
 
virtual Route getRoute ()
 
bool isDoomed ()
 
void setDoomed ()
 Request that this connection be shut down as soon as possible. More...
 
virtual void * send (const yarp::os::PortWriter &writer, yarp::os::PortReader *reader, const yarp::os::PortWriter *callback, void *tracker, const std::string &envelope, bool waitAfter=true, bool waitBefore=true, bool *gotReply=nullptr)
 Send a message on the connection. More...
 
virtual void * takeTracker ()
 Reacquire a tracker previously passed via send(). More...
 
virtual bool isBusy ()
 
virtual bool interrupt ()
 Interrupt the connection. More...
 
void setMode ()
 Check the carrier used for the connection, and see if it has a "log" modifier. More...
 
int getIndex ()
 
std::string getMode (bool *hasMode=nullptr)
 Read the "mode" of the connection - basically, whether it is used for logging or not. More...
 
bool isPupped () const
 
std::string getPupString () const
 
void setPupped (const std::string &pupString)
 Tag this connection as having been created by a publisherUpdate message to the port's administrative interface, and record the name of the target it services exactly as described in that message. More...
 
virtual void setCarrierParams (const yarp::os::Property &params)
 Set arbitrary parameters for this connection. More...
 
virtual void getCarrierParams (yarp::os::Property &params)
 
- Public Member Functions inherited from yarp::os::impl::ThreadImpl
virtual ~ThreadImpl ()
 
int join (double seconds=-1)
 
virtual void run ()
 
virtual void close ()
 
void askToClose ()
 
virtual bool start ()
 
bool isClosing ()
 
bool isRunning ()
 
virtual void beforeStart ()
 
virtual void afterStart (bool success)
 
virtual bool threadInit ()
 
virtual void threadRelease ()
 
long int getKey ()
 
void notify (bool s)
 
void notifyOpened (bool s)
 
void synchroWait ()
 
void synchroPost ()
 
int setPriority (int priority=-1, int policy=-1)
 
int getPriority ()
 
int getPolicy ()
 
long getTid ()
 

Protected Member Functions

PortCoregetOwner ()
 

Additional Inherited Members

- Static Public Member Functions inherited from yarp::os::impl::ThreadImpl
static int getCount ()
 
static long int getKeyOfCaller ()
 
static void yield ()
 
- Public Attributes inherited from yarp::os::impl::ThreadImpl
long tid {-1}
 
std::thread::id id
 

Detailed Description

This manages a single threaded resource related to a single input or output connection.

Definition at line 28 of file PortCoreUnit.h.

Constructor & Destructor Documentation

◆ PortCoreUnit()

yarp::os::impl::PortCoreUnit::PortCoreUnit ( PortCore owner,
int  index 
)
inline

Constructor.

Parameters
ownerthe port we call home
indexan id for this connection

Definition at line 38 of file PortCoreUnit.h.

◆ ~PortCoreUnit()

virtual yarp::os::impl::PortCoreUnit::~PortCoreUnit ( )
inlinevirtual

Destructor.

Definition at line 50 of file PortCoreUnit.h.

Member Function Documentation

◆ getCarrierParams()

virtual void yarp::os::impl::PortCoreUnit::getCarrierParams ( yarp::os::Property params)
inlinevirtual
Parameters
[out]

Reimplemented in yarp::os::impl::PortCoreOutputUnit, and yarp::os::impl::PortCoreInputUnit.

Definition at line 269 of file PortCoreUnit.h.

◆ getIndex()

int yarp::os::impl::PortCoreUnit::getIndex ( )
inline
Returns
the index identifier supplied to the constructor.

Definition at line 198 of file PortCoreUnit.h.

◆ getMode()

std::string yarp::os::impl::PortCoreUnit::getMode ( bool *  hasMode = nullptr)
inline

Read the "mode" of the connection - basically, whether it is used for logging or not.

Parameters
hasModeoptional variable to store whether a mode has been set
Returns
the connection mode, or the empty string if there is none

Definition at line 211 of file PortCoreUnit.h.

◆ getOwner()

PortCore& yarp::os::impl::PortCoreUnit::getOwner ( )
inlineprotected
Returns
the port to which this connection belongs

Definition at line 279 of file PortCoreUnit.h.

◆ getPupString()

std::string yarp::os::impl::PortCoreUnit::getPupString ( ) const
inline
Returns
the target this connection is serving, if created via a publisherUpdate message to the port's administrative interface. We need to know this so we can remove it if a succeeding call to publisherUpdate does not mention the target this connection is serving.

Definition at line 237 of file PortCoreUnit.h.

◆ getRoute()

virtual Route yarp::os::impl::PortCoreUnit::getRoute ( )
inlinevirtual
Returns
the route (sender, receiver, carrier) associated with this connection

Reimplemented in yarp::os::impl::PortCoreOutputUnit, and yarp::os::impl::PortCoreInputUnit.

Definition at line 83 of file PortCoreUnit.h.

◆ interrupt()

virtual bool yarp::os::impl::PortCoreUnit::interrupt ( )
inlinevirtual

Interrupt the connection.

Returns
true on success.

Reimplemented in yarp::os::impl::PortCoreInputUnit.

Definition at line 177 of file PortCoreUnit.h.

◆ isBusy()

virtual bool yarp::os::impl::PortCoreUnit::isBusy ( )
inlinevirtual
Returns
true if the connection is currently in use.

Reimplemented in yarp::os::impl::PortCoreOutputUnit, and yarp::os::impl::PortCoreInputUnit.

Definition at line 167 of file PortCoreUnit.h.

◆ isDoomed()

bool yarp::os::impl::PortCoreUnit::isDoomed ( )
inline
Returns
true if setDoomed() has been called to request that this connection be shut down

Definition at line 92 of file PortCoreUnit.h.

◆ isFinished()

virtual bool yarp::os::impl::PortCoreUnit::isFinished ( )
inlinevirtual
Returns
true if no further communication will occur using this connection

Reimplemented in yarp::os::impl::PortCoreOutputUnit, and yarp::os::impl::PortCoreInputUnit.

Definition at line 74 of file PortCoreUnit.h.

◆ isInput()

virtual bool yarp::os::impl::PortCoreUnit::isInput ( )
inlinevirtual
Returns
true if this is an input connection

Reimplemented in yarp::os::impl::PortCoreInputUnit.

Definition at line 57 of file PortCoreUnit.h.

◆ isOutput()

virtual bool yarp::os::impl::PortCoreUnit::isOutput ( )
inlinevirtual
Returns
true if this is an output connection

Reimplemented in yarp::os::impl::PortCoreOutputUnit.

Definition at line 65 of file PortCoreUnit.h.

◆ isPupped()

bool yarp::os::impl::PortCoreUnit::isPupped ( ) const
inline
Returns
true if this connection was created by a publisherUpdate message to the port's administrative interface. We need to know this so we can remove it if a succeeding call to publisherUpdate does not mention the target this connection is serving.

Definition at line 225 of file PortCoreUnit.h.

◆ send()

virtual void* yarp::os::impl::PortCoreUnit::send ( const yarp::os::PortWriter writer,
yarp::os::PortReader reader,
const yarp::os::PortWriter callback,
void *  tracker,
const std::string &  envelope,
bool  waitAfter = true,
bool  waitBefore = true,
bool *  gotReply = nullptr 
)
inlinevirtual

Send a message on the connection.

Does nothing for an input connection.

Parameters
writerthe message the send
readeran optional receiver for a reply
callbackan optional receiver for PortWriter::onCommencement and PortWriter::onCompletion calls
trackeran opaque pointer to an object doing memory management for the message. Once this pointer is passed to the send() method, it is "owned" until returned by a future call to send(), or by a call to takeTracker().
envelopesome optional text to pass along with the message
waitAftertrue if we should wait for the send to complete before the method returns
waitBeforetrue if we should wait for any in-progress send to complete before stating this one @parm gotReply if non-nullptr, this variable will be set to true if a reply was received
Returns
nullptr, or a tracker for a previous send operation that is no longer in progress. The tracker is an opaque pointer passed in via a previous call to send(). Once it is returned, it is the caller's responsibility to manage any memory associated with the message.

Reimplemented in yarp::os::impl::PortCoreOutputUnit.

Definition at line 130 of file PortCoreUnit.h.

◆ setCarrierParams()

virtual void yarp::os::impl::PortCoreUnit::setCarrierParams ( const yarp::os::Property params)
inlinevirtual

Set arbitrary parameters for this connection.

Parameters
paramsthe parameters to set

Reimplemented in yarp::os::impl::PortCoreOutputUnit, and yarp::os::impl::PortCoreInputUnit.

Definition at line 261 of file PortCoreUnit.h.

◆ setDoomed()

void yarp::os::impl::PortCoreUnit::setDoomed ( )
inline

Request that this connection be shut down as soon as possible.

Definition at line 100 of file PortCoreUnit.h.

◆ setMode()

void yarp::os::impl::PortCoreUnit::setMode ( )
inline

Check the carrier used for the connection, and see if it has a "log" modifier.

If so, set the connection "mode" from that modifier. A connection for which a mode is set will behave differently, sending log information on port activity rather than regular payload data.

Definition at line 189 of file PortCoreUnit.h.

◆ setPupped()

void yarp::os::impl::PortCoreUnit::setPupped ( const std::string &  pupString)
inline

Tag this connection as having been created by a publisherUpdate message to the port's administrative interface, and record the name of the target it services exactly as described in that message.

We need to know this so we can remove the connection if a succeeding call to publisherUpdate does not mention the target this connection is serving.

Definition at line 251 of file PortCoreUnit.h.

◆ takeTracker()

virtual void* yarp::os::impl::PortCoreUnit::takeTracker ( )
inlinevirtual

Reacquire a tracker previously passed via send().

This method may need to wait a send operation to complete before the tracker can be safely accessed.

Returns
the opaque tracker pointer passed to a previous call to send(), or nullptr if there is no such tracker. Once the tracker has been returned, calling this method again will return nullptr.

Reimplemented in yarp::os::impl::PortCoreOutputUnit.

Definition at line 159 of file PortCoreUnit.h.


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