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

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

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

Detailed Description

Definition at line 151 of file PortCore.h.

Public Member Functions

 PortCore ()
 Constructor. More...
 
 ~PortCore ()
 Destructor. More...
 
bool addOutput (const std::string &dest, void *id, yarp::os::OutputStream *os, bool onlyIfNeeded=false)
 Add an output connection to this port. More...
 
void addOutput (OutputProtocol *op)
 Add another output to the port. More...
 
void removeInput (const std::string &src, void *id, yarp::os::OutputStream *os)
 Remove an input connection. More...
 
void removeOutput (const std::string &dest, void *id, yarp::os::OutputStream *os)
 Remove an output connection. More...
 
bool removeIO (const Route &route, bool synch=false)
 Remove any connection matching the supplied route. More...
 
void describe (void *id, yarp::os::OutputStream *os)
 Produce a text description of the port and its connections. More...
 
void describe (yarp::os::PortReport &reporter)
 Generate a description of the connections associated with the port. More...
 
bool readBlock (ConnectionReader &reader, void *id, yarp::os::OutputStream *os)
 Read a block of regular payload data. More...
 
bool adminBlock (ConnectionReader &reader, void *id)
 Read a block of administrative data. More...
 
void setName (const std::string &name)
 Set the name of this port. More...
 
std::string getName ()
 
void setEnvelope (const std::string &envelope)
 Set some envelope information to pass along with a message without actually being part of the message. More...
 
bool setEnvelope (yarp::os::PortWriter &envelope)
 Set some extra meta data to pass along with the message. More...
 
std::string getEnvelope ()
 
bool getEnvelope (yarp::os::PortReader &envelope)
 Get any meta data associated with the last message received. More...
 
void report (const yarp::os::PortInfo &info)
 Handle a port event (connection, disconnection, etc) Generate a description of the connections associated with the port. More...
 
void reportUnit (PortCoreUnit *unit, bool active)
 Called by a connection handler with active=true just after it is fully configured, and with active=false just before it shuts itself down. More...
 
void setFlags (unsigned int flags)
 Configure the port to meet certain restrictions in behavior. More...
 
void setContactable (Contactable *contactable)
 
unsigned int getFlags ()
 Check current configuration of port. More...
 
bool listen (const Contact &address, bool shouldAnnounce=true)
 Begin service at a given address. More...
 
bool isWriting ()
 Check if a message is currently being sent. More...
 
int getInputCount ()
 Check how many input connections there are. More...
 
int getOutputCount ()
 Check how many output connections there are. More...
 
void setReadHandler (yarp::os::PortReader &reader)
 Set a callback for incoming data. More...
 
void setAdminReadHandler (yarp::os::PortReader &reader)
 Set a callback for incoming administrative messages. More...
 
void setReadCreator (yarp::os::PortReaderCreator &creator)
 Set a callback for creating callbacks for incoming data. More...
 
void setWaitBeforeSend (bool waitBeforeSend)
 Upon being asked to send a message, should we wait for any existing message to be sent to all destinations? More...
 
void setWaitAfterSend (bool waitAfterSend)
 After sending a message, should we wait for it to be sent to all destinations before returning? More...
 
bool read (yarp::os::ConnectionReader &reader) override
 Callback for data. More...
 
bool start () override
 Begin main thread. More...
 
bool manualStart (const char *sourceName)
 Start up the port, but without a main thread. More...
 
bool send (const yarp::os::PortWriter &writer, yarp::os::PortReader *reader=nullptr, const yarp::os::PortWriter *callback=nullptr)
 Send a normal message. More...
 
bool sendHelper (const yarp::os::PortWriter &writer, int mode, yarp::os::PortReader *reader=nullptr, const yarp::os::PortWriter *callback=nullptr)
 Send a message with a specific mode (normal or log). More...
 
void close () override
 Shut down port. More...
 
void run () override
 The body of the main thread. More...
 
int getEventCount ()
 A diagnostic for testing purposes. More...
 
const ContactgetAddress () const
 Get the address associated with the port. More...
 
void resetPortName (const std::string &str)
 
yarp::os::PortReaderCreatorgetReadCreator ()
 Get the creator of callbacks. More...
 
void notifyCompletion (void *tracker)
 Call the right onCompletion() after sending message. More...
 
void setControlRegistration (bool flag)
 Normally the port will unregister its name with the name server when shutting down. More...
 
void interrupt ()
 Prepare the port to be shut down. More...
 
void resume ()
 Undo an interrupt() More...
 
void setReportCallback (yarp::os::PortReport *reporter)
 Set a callback to be notified of changes in port status. More...
 
void resetReportCallback ()
 Reset the callback to be notified of changes in port status. More...
 
bool isListening () const
 
bool isManual () const
 
bool isInterrupted () const
 
void setTimeout (float timeout)
 
PropertyacquireProperties (bool readOnly)
 
void releaseProperties (Property *prop)
 
bool setCallbackLock (yarp::os::Mutex *mutex)
 
bool setCallbackLock (std::mutex *mutex=nullptr)
 
bool removeCallbackLock ()
 
bool lockCallback ()
 
bool tryLockCallback ()
 
void unlockCallback ()
 
yarp::os::impl::PortDataModifiergetPortModifier ()
 
void checkType (PortReader &reader)
 
yarp::os::Type getType ()
 
void promiseType (const Type &typ)
 
- Public Member Functions inherited from yarp::os::impl::ThreadImpl
virtual ~ThreadImpl ()
 
int join (double seconds=-1)
 
void askToClose ()
 
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 ()
 
- Public Member Functions inherited from yarp::os::PortReader
virtual ~PortReader ()
 Destructor. More...
 
virtual Type getReadType () const
 

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
 

Constructor & Destructor Documentation

◆ PortCore()

PortCore::PortCore ( )
default

Constructor.

◆ ~PortCore()

PortCore::~PortCore ( )

Destructor.

Definition at line 64 of file PortCore.cpp.

Member Function Documentation

◆ acquireProperties()

Property * PortCore::acquireProperties ( bool  readOnly)

Definition at line 2969 of file PortCore.cpp.

◆ addOutput() [1/2]

bool PortCore::addOutput ( const std::string &  dest,
void *  id,
yarp::os::OutputStream os,
bool  onlyIfNeeded = false 
)

Add an output connection to this port.

Parameters
destthe name of the target
idan opaque tracker for the connection
osthe output stream for messages about this operation
onlyIfNeededif true, don't add the connection if there is already a connection to the named target
Returns
true on success

Definition at line 857 of file PortCore.cpp.

◆ addOutput() [2/2]

void PortCore::addOutput ( OutputProtocol op)

Add another output to the port.

Definition at line 702 of file PortCore.cpp.

◆ adminBlock()

bool PortCore::adminBlock ( ConnectionReader reader,
void *  id 
)

Read a block of administrative data.

Process an administrative message.

Parameters
readersource of data
idopaque identifier of connection providing data

Definition at line 1682 of file PortCore.cpp.

◆ checkType()

void PortCore::checkType ( PortReader reader)

Definition at line 3147 of file PortCore.cpp.

◆ close()

void PortCore::close ( )
overridevirtual

Shut down port.

Reimplemented from yarp::os::impl::ThreadImpl.

Definition at line 269 of file PortCore.cpp.

◆ describe() [1/2]

void PortCore::describe ( void *  id,
yarp::os::OutputStream os 
)

Produce a text description of the port and its connections.

Parameters
idopaque identifier of connection that needs the description
osstream to write on

Definition at line 1064 of file PortCore.cpp.

◆ describe() [2/2]

void PortCore::describe ( yarp::os::PortReport reporter)

Generate a description of the connections associated with the port.

Definition at line 1121 of file PortCore.cpp.

◆ getAddress()

const Contact & PortCore::getAddress ( ) const

Get the address associated with the port.

Definition at line 3011 of file PortCore.cpp.

◆ getEnvelope() [1/2]

std::string PortCore::getEnvelope ( )

Definition at line 1494 of file PortCore.cpp.

◆ getEnvelope() [2/2]

bool PortCore::getEnvelope ( yarp::os::PortReader envelope)

Get any meta data associated with the last message received.

Definition at line 1499 of file PortCore.cpp.

◆ getEventCount()

int PortCore::getEventCount ( )

A diagnostic for testing purposes.

Definition at line 535 of file PortCore.cpp.

◆ getFlags()

unsigned int yarp::os::impl::PortCore::getFlags ( )
inline

Check current configuration of port.

Definition at line 308 of file PortCore.h.

◆ getInputCount()

int PortCore::getInputCount ( )

Check how many input connections there are.

Definition at line 1437 of file PortCore.cpp.

◆ getName()

std::string PortCore::getName ( )
Returns
the name of this port

Definition at line 2996 of file PortCore.cpp.

◆ getOutputCount()

int PortCore::getOutputCount ( )

Check how many output connections there are.

Definition at line 1446 of file PortCore.cpp.

◆ getPortModifier()

yarp::os::impl::PortDataModifier & PortCore::getPortModifier ( )

Definition at line 3142 of file PortCore.cpp.

◆ getReadCreator()

yarp::os::PortReaderCreator * PortCore::getReadCreator ( )

Get the creator of callbacks.

Definition at line 3021 of file PortCore.cpp.

◆ getType()

yarp::os::Type PortCore::getType ( )

Definition at line 3159 of file PortCore.cpp.

◆ interrupt()

void PortCore::interrupt ( )

Prepare the port to be shut down.

Definition at line 337 of file PortCore.cpp.

◆ isInterrupted()

bool PortCore::isInterrupted ( ) const
Returns
true if port operation has been interrupted.

Definition at line 3041 of file PortCore.cpp.

◆ isListening()

bool PortCore::isListening ( ) const
Returns
true if there is a server socket/thread currently associated with this port.

Definition at line 3031 of file PortCore.cpp.

◆ isManual()

bool PortCore::isManual ( ) const
Returns
true if there the port is configured to operate without a server socket/thread.

Definition at line 3036 of file PortCore.cpp.

◆ isWriting()

bool PortCore::isWriting ( )

Check if a message is currently being sent.

Definition at line 1415 of file PortCore.cpp.

◆ listen()

bool PortCore::listen ( const Contact address,
bool  shouldAnnounce = true 
)

Begin service at a given address.

Definition at line 71 of file PortCore.cpp.

◆ lockCallback()

bool PortCore::lockCallback ( )

Definition at line 3095 of file PortCore.cpp.

◆ manualStart()

bool PortCore::manualStart ( const char *  sourceName)

Start up the port, but without a main thread.

Definition at line 314 of file PortCore.cpp.

◆ notifyCompletion()

void PortCore::notifyCompletion ( void *  tracker)

Call the right onCompletion() after sending message.

Definition at line 1456 of file PortCore.cpp.

◆ promiseType()

void PortCore::promiseType ( const Type typ)

Definition at line 3167 of file PortCore.cpp.

◆ read()

bool yarp::os::impl::PortCore::read ( yarp::os::ConnectionReader reader)
inlineoverridevirtual

Callback for data.

Implements yarp::os::PortReader.

Reimplemented in yarp::os::impl::PortCoreAdapter.

Definition at line 369 of file PortCore.h.

◆ readBlock()

bool PortCore::readBlock ( ConnectionReader reader,
void *  id,
yarp::os::OutputStream os 
)

Read a block of regular payload data.

Parameters
readersource of data
idopaque identifier of connection providing data
osstream to write error messages on

Definition at line 1218 of file PortCore.cpp.

◆ releaseProperties()

void PortCore::releaseProperties ( Property prop)

Definition at line 2980 of file PortCore.cpp.

◆ removeCallbackLock()

bool PortCore::removeCallbackLock ( )

Definition at line 3082 of file PortCore.cpp.

◆ removeInput()

void PortCore::removeInput ( const std::string &  src,
void *  id,
yarp::os::OutputStream os 
)

Remove an input connection.

Parameters
srcthe name of the source port
idan opaque tracker for the connection
osthe output stream for messages about this operation

Definition at line 1046 of file PortCore.cpp.

◆ removeIO()

bool PortCore::removeIO ( const Route route,
bool  synch = false 
)

Remove any connection matching the supplied route.

Parameters
routethe source/target/carrier associated with the connection
synchtrue if we should wait for removal to complete
Returns
true if a connection was found that needed removal

Definition at line 2986 of file PortCore.cpp.

◆ removeOutput()

void PortCore::removeOutput ( const std::string &  dest,
void *  id,
yarp::os::OutputStream os 
)

Remove an output connection.

Parameters
destthe name of the target port
idan opaque tracker for the connection
osthe output stream for messages about this operation

Definition at line 1028 of file PortCore.cpp.

◆ report()

void PortCore::report ( const yarp::os::PortInfo info)

Handle a port event (connection, disconnection, etc) Generate a description of the connections associated with the port.

Parameters
infothe event description

Definition at line 1204 of file PortCore.cpp.

◆ reportUnit()

void PortCore::reportUnit ( PortCoreUnit unit,
bool  active 
)

Called by a connection handler with active=true just after it is fully configured, and with active=false just before it shuts itself down.

Parameters
unitthe connection handler starting up / shutting down
activetrue if the handler is starting up, false if shutting down

Definition at line 2914 of file PortCore.cpp.

◆ resetPortName()

void PortCore::resetPortName ( const std::string &  str)

Definition at line 3016 of file PortCore.cpp.

◆ resetReportCallback()

void PortCore::resetReportCallback ( )

Reset the callback to be notified of changes in port status.

Definition at line 1197 of file PortCore.cpp.

◆ resume()

void PortCore::resume ( )

Undo an interrupt()

Definition at line 331 of file PortCore.cpp.

◆ run()

void PortCore::run ( )
overridevirtual

The body of the main thread.

Reimplemented from yarp::os::impl::ThreadImpl.

Definition at line 167 of file PortCore.cpp.

◆ send()

bool PortCore::send ( const yarp::os::PortWriter writer,
yarp::os::PortReader reader = nullptr,
const yarp::os::PortWriter callback = nullptr 
)

Send a normal message.

Parameters
writerthe message
readerwhere to direct replies
callbackwho to call onCompletion() on when message sent.

Definition at line 1267 of file PortCore.cpp.

◆ sendHelper()

bool PortCore::sendHelper ( const yarp::os::PortWriter writer,
int  mode,
yarp::os::PortReader reader = nullptr,
const yarp::os::PortWriter callback = nullptr 
)

Send a message with a specific mode (normal or log).

Parameters
writerthe message
readerwhere to direct replies
callbackwho to call onCompletion() on when message sent.

Definition at line 1291 of file PortCore.cpp.

◆ setAdminReadHandler()

void PortCore::setAdminReadHandler ( yarp::os::PortReader reader)

Set a callback for incoming administrative messages.

Definition at line 150 of file PortCore.cpp.

◆ setCallbackLock() [1/2]

bool PortCore::setCallbackLock ( std::mutex *  mutex = nullptr)

Definition at line 3069 of file PortCore.cpp.

◆ setCallbackLock() [2/2]

bool PortCore::setCallbackLock ( yarp::os::Mutex mutex)

Definition at line 3054 of file PortCore.cpp.

◆ setContactable()

void yarp::os::impl::PortCore::setContactable ( Contactable contactable)
inline

Definition at line 300 of file PortCore.h.

◆ setControlRegistration()

void PortCore::setControlRegistration ( bool  flag)

Normally the port will unregister its name with the name server when shutting down.

This can be inhibited.

Definition at line 3026 of file PortCore.cpp.

◆ setEnvelope() [1/2]

void PortCore::setEnvelope ( const std::string &  envelope)

Set some envelope information to pass along with a message without actually being part of the message.

Parameters
envelopethe extra message to send

Definition at line 1480 of file PortCore.cpp.

◆ setEnvelope() [2/2]

bool PortCore::setEnvelope ( yarp::os::PortWriter envelope)

Set some extra meta data to pass along with the message.

Definition at line 1469 of file PortCore.cpp.

◆ setFlags()

void yarp::os::impl::PortCore::setFlags ( unsigned int  flags)
inline

Configure the port to meet certain restrictions in behavior.

Definition at line 295 of file PortCore.h.

◆ setName()

void PortCore::setName ( const std::string &  name)

Set the name of this port.

Parameters
namethe name of this port

Definition at line 2991 of file PortCore.cpp.

◆ setReadCreator()

void PortCore::setReadCreator ( yarp::os::PortReaderCreator creator)

Set a callback for creating callbacks for incoming data.

Definition at line 158 of file PortCore.cpp.

◆ setReadHandler()

void PortCore::setReadHandler ( yarp::os::PortReader reader)

Set a callback for incoming data.

Definition at line 142 of file PortCore.cpp.

◆ setReportCallback()

void PortCore::setReportCallback ( yarp::os::PortReport reporter)

Set a callback to be notified of changes in port status.

Definition at line 1188 of file PortCore.cpp.

◆ setTimeout()

void PortCore::setTimeout ( float  timeout)

Definition at line 3046 of file PortCore.cpp.

◆ setWaitAfterSend()

void yarp::os::impl::PortCore::setWaitAfterSend ( bool  waitAfterSend)
inline

After sending a message, should we wait for it to be sent to all destinations before returning?

Definition at line 361 of file PortCore.h.

◆ setWaitBeforeSend()

void yarp::os::impl::PortCore::setWaitBeforeSend ( bool  waitBeforeSend)
inline

Upon being asked to send a message, should we wait for any existing message to be sent to all destinations?

Definition at line 352 of file PortCore.h.

◆ start()

bool PortCore::start ( )
overridevirtual

Begin main thread.

Reimplemented from yarp::os::impl::ThreadImpl.

Definition at line 282 of file PortCore.cpp.

◆ tryLockCallback()

bool PortCore::tryLockCallback ( )

Definition at line 3112 of file PortCore.cpp.

◆ unlockCallback()

void PortCore::unlockCallback ( )

Definition at line 3127 of file PortCore.cpp.


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