YARP  2.3.70.1
Yet Another Robot Platform
yarp::os::BufferedPort< T > Class Template Reference

A mini-server for performing network communication in the background. More...

#include <yarp/os/BufferedPort.h>

+ Inheritance diagram for yarp::os::BufferedPort< T >:

Public Types

typedef T ContentType
 The type of content stored by this BufferedPort. More...
 

Public Member Functions

 BufferedPort ()
 Constructor. More...
 
 BufferedPort (Port &port)
 Wrap an existing unbuffered port. More...
 
virtual ~BufferedPort ()
 Destructor. More...
 
virtual bool open (const ConstString &name) YARP_OVERRIDE
 Start port operation, with a specific name, with automatically-chosen network parameters. More...
 
virtual bool open (const Contact &contact, bool registerName=true) YARP_OVERRIDE
 Start port operation with user-chosen network parameters. More...
 
virtual bool addOutput (const ConstString &name) YARP_OVERRIDE
 Add an output connection to the specified port. More...
 
virtual bool addOutput (const ConstString &name, const ConstString &carrier) YARP_OVERRIDE
 Add an output connection to the specified port, using a specified carrier. More...
 
virtual bool addOutput (const Contact &contact) YARP_OVERRIDE
 Add an output connection to the specified port, using specified network parameters. More...
 
virtual void close () YARP_OVERRIDE
 Stop port activity. More...
 
virtual void interrupt () YARP_OVERRIDE
 Interrupt any current reads or writes attached to the port. More...
 
virtual void resume () YARP_OVERRIDE
 Put the port back in an operative state after interrupt() has been called. More...
 
virtual int getPendingReads () YARP_OVERRIDE
 Get the number of objects ready to be read. More...
 
virtual Contact where () const YARP_OVERRIDE
 Returns information about how this port can be reached. More...
 
virtual ConstString getName () const YARP_OVERRIDE
 Get name of port. More...
 
T & prepare ()
 Access the object which will be transmitted by the next call to yarp::os::BufferedPort::write. More...
 
bool unprepare ()
 Give the last prepared object back to YARP without writing it. More...
 
void write (bool forceStrict=false)
 Write the current object being returned by BufferedPort::prepare. More...
 
void writeStrict ()
 Write the current object being returned by BufferedPort::prepare, waiting until any previous sends are complete. More...
 
void waitForWrite ()
 Wait for any pending writes to complete. More...
 
void setStrict (bool strict=true) YARP_OVERRIDE
 Never drop any messages read. More...
 
virtual T * read (bool shouldWait=true) YARP_OVERRIDE
 Read a message from the port. More...
 
virtual T * lastRead () YARP_OVERRIDE
 Get the last data returned by read() More...
 
virtual bool isClosed () YARP_OVERRIDE
 
void setReplier (PortReader &reader) YARP_OVERRIDE
 If a message is received that requires a reply, use this handler. More...
 
void setReader (PortReader &reader) YARP_OVERRIDE
 Set an external reader for port data. More...
 
void setAdminReader (PortReader &reader) YARP_OVERRIDE
 Set an external reader for unrecognized administrative port messages. More...
 
virtual void onRead (T &datum) YARP_OVERRIDE
 this method will be called with new data, as long as you've requested this be done by calling useCallback() More...
 
void useCallback (TypedReaderCallback< T > &callback) YARP_OVERRIDE
 Set an object whose onRead method will be called when data is available. More...
 
void useCallback ()
 Call own onRead() method – user can override that method to be informed about data as it arrives. More...
 
void disableCallback () YARP_OVERRIDE
 Remove a callback set up with useCallback() More...
 
virtual bool setEnvelope (PortWriter &envelope) YARP_OVERRIDE
 Set an envelope (e.g., a timestamp) to the next message which will be sent. More...
 
virtual bool getEnvelope (PortReader &envelope) YARP_OVERRIDE
 Get the envelope information (e.g., a timestamp) from the last message received on the port. More...
 
virtual int getInputCount () YARP_OVERRIDE
 Determine how many connections are arriving into this port. More...
 
virtual int getOutputCount () YARP_OVERRIDE
 Determine how many output connections this port has. More...
 
bool isWriting () YARP_OVERRIDE
 Report whether the port is currently writing data. More...
 
virtual void getReport (PortReport &reporter) YARP_OVERRIDE
 Get information on the state of the port - connections etc. More...
 
virtual void setReporter (PortReport &reporter) YARP_OVERRIDE
 Set a callback to be called upon any future connections and disconnections to/from the port. More...
 
virtual void resetReporter () YARP_OVERRIDE
 Remove the callback which is called upon any future connections and disconnections to/from the port. More...
 
virtual void * acquire () YARP_OVERRIDE
 Take control of the last object read. More...
 
virtual void release (void *handle) YARP_OVERRIDE
 Return control to YARP of an object previously taken control of with the acquire() method. More...
 
virtual void setTargetPeriod (double period) YARP_OVERRIDE
 Try to provide data periodically. More...
 
virtual Type getType () YARP_OVERRIDE
 Get the type of data the port has committed to send/receive. More...
 
virtual void promiseType (const Type &typ) YARP_OVERRIDE
 Commit the port to a particular type of data. More...
 
virtual void setInputMode (bool expectInput) YARP_OVERRIDE
 Configure the port to allow or forbid inputs. More...
 
virtual void setOutputMode (bool expectOutput) YARP_OVERRIDE
 Configure the port to allow or forbid outputs. More...
 
virtual void setRpcMode (bool expectRpc) YARP_OVERRIDE
 Configure the port to be RPC only. More...
 
virtual PropertyacquireProperties (bool readOnly) YARP_OVERRIDE
 Access unstructured port properties. More...
 
virtual void releaseProperties (Property *prop) YARP_OVERRIDE
 End access unstructured port properties. More...
 
virtual void includeNodeInName (bool flag) YARP_OVERRIDE
 Choose whether to prepend a node name (if one is available) to the port's name. More...
 
virtual bool setCallbackLock (yarp::os::Mutex *mutex) YARP_OVERRIDE
 Add a lock to use when invoking callbacks. More...
 
virtual bool removeCallbackLock () YARP_OVERRIDE
 Remove a lock on callbacks added with setCallbackLock() More...
 
virtual bool lockCallback () YARP_OVERRIDE
 Lock callbacks until unlockCallback() is called. More...
 
virtual bool tryLockCallback () YARP_OVERRIDE
 Try to lock callbacks until unlockCallback() is called. More...
 
virtual void unlockCallback () YARP_OVERRIDE
 Unlock callbacks. More...
 
- Public Member Functions inherited from yarp::os::Contactable
virtual ~Contactable ()
 Destructor. More...
 
bool open ()
 Start port operation, with automatically-chosen network parameters. More...
 
void setReadOnly ()
 Shorthand for setInputMode(true), setOutputMode(false), setRpcMode(false) More...
 
void setWriteOnly ()
 Shorthand for setInputMode(false), setOutputMode(true), setRpcMode(false) More...
 
void setRpcServer ()
 Shorthand for setInputMode(true), setOutputMode(false), setRpcMode(true) More...
 
void setRpcClient ()
 Shorthand for setInputMode(false), setOutputMode(true), setRpcMode(true) More...
 
- Public Member Functions inherited from yarp::os::TypedReader< T >
virtual ~TypedReader ()
 Destructor. More...
 
- Public Member Functions inherited from yarp::os::TypedReaderCallback< T >
virtual ~TypedReaderCallback ()
 Destructor. More...
 
virtual void onRead (T &datum, const yarp::os::TypedReader< T > &reader)
 Callback method. More...
 

Private Member Functions

 BufferedPort (const BufferedPort &alt)
 
const BufferedPortoperator= (const BufferedPort &alt)
 
void attachIfNeeded ()
 
bool sharedOpen (Port &port)
 

Private Attributes

PortWriterBuffer< T > writer
 
Port port
 
PortReaderBuffer< T > reader
 
bool interrupted
 
bool attached
 

Detailed Description

template<class T>
class yarp::os::BufferedPort< T >

A mini-server for performing network communication in the background.

If you are a beginner, you might want to use the yarp::os::Port class first, and then come back to BufferedPort when you want to send and receive messages in the background without having to stop your processing. This is convenient, but requires a little care to understand the life-cycle of objects written to and read from the network (see BufferedPort::read and BufferedPort::write).

By default a BufferedPort attempts to reduce latency between senders and receivers. To do so messages may be dropped by the writer if BufferedPort::write is called too quickly. The reader may also drop old messages if BufferedPort::read is not called fast enough, so that new messages can travel with high priority. This policy is sometimes called Oldest Packet Drop (ODP).

If your application cannot afford dropping messages you can change the buffering policy. Use BufferedPort::writeStrict() when writing to a port, this waits for pending transmissions to be finished before writing new data. Call BufferedPort::setStrict() to change the buffering policy to FIFO at the receiver side. In this way all messages will be stored inside the BufferedPort and delivered to the reader. Pay attention that in this case a slow reader may cause increasing latency and memory use.

Methods that can be useful to monitor the status of read and write operations are: yarp::os::BufferedPort::getPendingReads() and yarp::os::BufferedPort::isWriting().

For examples and help, see:

Examples:
os/image_process.cpp, os/image_process_module.cpp, os/image_source.cpp, port_power/ex0301_buffered_callback.cpp, and portaudio/sound_receiver.cpp.

Definition at line 17 of file BufferedPort.h.

Member Typedef Documentation

◆ ContentType

template<class T>
typedef T yarp::os::BufferedPort< T >::ContentType

The type of content stored by this BufferedPort.

Definition at line 67 of file BufferedPort.h.

Constructor & Destructor Documentation

◆ BufferedPort() [1/3]

template<class T>
yarp::os::BufferedPort< T >::BufferedPort ( )
inline

Constructor.

Definition at line 72 of file BufferedPort.h.

◆ BufferedPort() [2/3]

template<class T>
yarp::os::BufferedPort< T >::BufferedPort ( Port port)
inline

Wrap an existing unbuffered port.

Definition at line 83 of file BufferedPort.h.

◆ ~BufferedPort()

template<class T>
virtual yarp::os::BufferedPort< T >::~BufferedPort ( )
inlinevirtual

Destructor.

Definition at line 92 of file BufferedPort.h.

◆ BufferedPort() [3/3]

template<class T>
yarp::os::BufferedPort< T >::BufferedPort ( const BufferedPort< T > &  alt)
inlineprivate

Definition at line 440 of file BufferedPort.h.

Member Function Documentation

◆ acquire()

template<class T>
virtual void* yarp::os::BufferedPort< T >::acquire ( )
inlinevirtual

Take control of the last object read.

YARP will not reuse that object until it is explicitly released by the user. Be careful - if you acquire objects without releasing, YARP will keep making new ones to store incoming messages. So you need to release all objects you acquire eventually to avoid running out of memory.

Returns
the handle to call release() with in order to give YARP back control of the last object read.

Implements yarp::os::TypedReader< T >.

Definition at line 363 of file BufferedPort.h.

◆ acquireProperties()

template<class T>
virtual Property* yarp::os::BufferedPort< T >::acquireProperties ( bool  readOnly)
inlinevirtual

Access unstructured port properties.

Parameters
readOnlyset this if you won't be modifying the properties.
Returns
the port properties (or YARP_NULLPTR if readOnly and none have been set)

Implements yarp::os::Contactable.

Definition at line 400 of file BufferedPort.h.

◆ addOutput() [1/3]

template<class T>
virtual bool yarp::os::BufferedPort< T >::addOutput ( const ConstString name)
inlinevirtual

Add an output connection to the specified port.

Parameters
namethe name of the target port
Returns
true iff the connection is successfully created

Implements yarp::os::Contactable.

Definition at line 110 of file BufferedPort.h.

◆ addOutput() [2/3]

template<class T>
virtual bool yarp::os::BufferedPort< T >::addOutput ( const ConstString name,
const ConstString carrier 
)
inlinevirtual

Add an output connection to the specified port, using a specified carrier.

Parameters
namethe name of the target port
carrierthe carrier (network protocol) to use, e.g. "tcp", "udp", "mcast", "text", ...
Returns
true iff the connection is successfully created

Implements yarp::os::Contactable.

Definition at line 115 of file BufferedPort.h.

◆ addOutput() [3/3]

template<class T>
virtual bool yarp::os::BufferedPort< T >::addOutput ( const Contact contact)
inlinevirtual

Add an output connection to the specified port, using specified network parameters.

Parameters
contactinformation on how to reach the target
Returns
true iff the connection is successfully created

Implements yarp::os::Contactable.

Definition at line 120 of file BufferedPort.h.

◆ attachIfNeeded()

template<class T>
void yarp::os::BufferedPort< T >::attachIfNeeded ( )
inlineprivate

Definition at line 450 of file BufferedPort.h.

◆ close()

template<class T>
virtual void yarp::os::BufferedPort< T >::close ( )
inlinevirtual

Stop port activity.

Implements yarp::os::Contactable.

Definition at line 125 of file BufferedPort.h.

◆ disableCallback()

template<class T>
void yarp::os::BufferedPort< T >::disableCallback ( )
inlinevirtual

Remove a callback set up with useCallback()

Implements yarp::os::TypedReader< T >.

Definition at line 316 of file BufferedPort.h.

◆ getEnvelope()

template<class T>
virtual bool yarp::os::BufferedPort< T >::getEnvelope ( PortReader envelope)
inlinevirtual

Get the envelope information (e.g., a timestamp) from the last message received on the port.

You must be sure to match the type of your envelope for getEnvelope with whatever is being sent using setEnvelope. The Stamp class is a typical choice for timestamps. The Bottle class also works as an envelope, but it is not specialized to be efficient.

Parameters
enveloperecipient for envelope information for last message received by port.
Returns
true iff reading the envelope was successful

Implements yarp::os::Contactable.

Definition at line 328 of file BufferedPort.h.

◆ getInputCount()

template<class T>
virtual int yarp::os::BufferedPort< T >::getInputCount ( )
inlinevirtual

Determine how many connections are arriving into this port.

In other words, how many other ports have this port listed as an output?

Returns
number of input connections

Implements yarp::os::Contactable.

Definition at line 333 of file BufferedPort.h.

◆ getName()

template<class T>
virtual ConstString yarp::os::BufferedPort< T >::getName ( ) const
inlinevirtual

Get name of port.

Returns
name of port

Reimplemented from yarp::os::Contactable.

Definition at line 156 of file BufferedPort.h.

◆ getOutputCount()

template<class T>
virtual int yarp::os::BufferedPort< T >::getOutputCount ( )
inlinevirtual

Determine how many output connections this port has.

Returns
number of output connections

Implements yarp::os::Contactable.

Definition at line 338 of file BufferedPort.h.

◆ getPendingReads()

template<class T>
virtual int yarp::os::BufferedPort< T >::getPendingReads ( )
inlinevirtual

Get the number of objects ready to be read.

Implements yarp::os::TypedReader< T >.

Definition at line 146 of file BufferedPort.h.

◆ getReport()

template<class T>
virtual void yarp::os::BufferedPort< T >::getReport ( PortReport reporter)
inlinevirtual

Get information on the state of the port - connections etc.

PortReport::report will be called once for each connection to the port that exists right now. To request callbacks for any future connections/disconnections, use the setReporter method instead.

Parameters
reportercallback for port event/state information

Implements yarp::os::Contactable.

Definition at line 348 of file BufferedPort.h.

◆ getType()

template<class T>
virtual Type yarp::os::BufferedPort< T >::getType ( )
inlinevirtual

Get the type of data the port has committed to send/receive.

Not all ports commit to a particular type of data.

Returns
type of data to expect/provide

Implements yarp::os::Contactable.

Definition at line 379 of file BufferedPort.h.

◆ includeNodeInName()

template<class T>
virtual void yarp::os::BufferedPort< T >::includeNodeInName ( bool  flag)
inlinevirtual

Choose whether to prepend a node name (if one is available) to the port's name.

Node names are set using yarp::os::Node.

Parameters
flagtrue if the node name should be added to port names

Implements yarp::os::Contactable.

Definition at line 408 of file BufferedPort.h.

◆ interrupt()

template<class T>
virtual void yarp::os::BufferedPort< T >::interrupt ( )
inlinevirtual

Interrupt any current reads or writes attached to the port.

This is useful prior to calling close(), if there are multiple threads operating on the port. Any reads or writes after the call to interrupt() will fail - unless resume() is called.

Implements yarp::os::Contactable.

Definition at line 133 of file BufferedPort.h.

◆ isClosed()

template<class T>
virtual bool yarp::os::BufferedPort< T >::isClosed ( )
inlinevirtual
Returns
true if Port associated with this reader has been closed

Implements yarp::os::TypedReader< T >.

Definition at line 270 of file BufferedPort.h.

◆ isWriting()

template<class T>
bool yarp::os::BufferedPort< T >::isWriting ( )
inlinevirtual

Report whether the port is currently writing data.

Returns
true iff the port is writing in the background.

Implements yarp::os::Contactable.

Definition at line 343 of file BufferedPort.h.

◆ lastRead()

template<class T>
virtual T* yarp::os::BufferedPort< T >::lastRead ( )
inlinevirtual

Get the last data returned by read()

Returns
pointer to last data returned by read(), or YARP_NULLPTR on failure.

Implements yarp::os::TypedReader< T >.

Definition at line 266 of file BufferedPort.h.

◆ lockCallback()

template<class T>
virtual bool yarp::os::BufferedPort< T >::lockCallback ( )
inlinevirtual

Lock callbacks until unlockCallback() is called.

Has no effect if no lock has been set via a call to setCallbackLock(). Will block if callbacks are already locked.

Returns
true if callbacks were locked

Implements yarp::os::Contactable.

Definition at line 420 of file BufferedPort.h.

◆ onRead()

template<class T>
virtual void yarp::os::BufferedPort< T >::onRead ( T &  datum)
inlinevirtual

this method will be called with new data, as long as you've requested this be done by calling useCallback()

Reimplemented from yarp::os::TypedReaderCallback< T >.

Reimplemented in yarp::dev::JoypadControl::JoyPort< T >, and InputCallback.

Definition at line 293 of file BufferedPort.h.

◆ open() [1/2]

template<class T>
virtual bool yarp::os::BufferedPort< T >::open ( const ConstString name)
inlinevirtual

Start port operation, with a specific name, with automatically-chosen network parameters.

The port is registered with the given name, and allocated network resources, by communicating with the YARP name server.

Returns
true iff the port started operation successfully and is now visible on the YARP network

Implements yarp::os::Contactable.

Definition at line 98 of file BufferedPort.h.

◆ open() [2/2]

template<class T>
virtual bool yarp::os::BufferedPort< T >::open ( const Contact contact,
bool  registerName = true 
)
inlinevirtual

Start port operation with user-chosen network parameters.

Contact information is supplied by the user rather than the name server. If the Contact information is incomplete, the name server is used to complete it (set registerName to false if you don't want name server help).

Returns
true iff the port started operation successfully and is now visible on the YARP network

Implements yarp::os::Contactable.

Definition at line 104 of file BufferedPort.h.

◆ operator=()

template<class T>
const BufferedPort& yarp::os::BufferedPort< T >::operator= ( const BufferedPort< T > &  alt)
inlineprivate

Definition at line 445 of file BufferedPort.h.

◆ prepare()

template<class T>
T& yarp::os::BufferedPort< T >::prepare ( )
inline

Access the object which will be transmitted by the next call to yarp::os::BufferedPort::write.

The object can safely be modified by the user of this class, to prepare it. Extra objects will be created or reused as necessary depending on the state of communication with the output(s) of the port. Be careful! If prepare() gives you a reused object, it is up to the user to clear the object if that is appropriate. If you are sending yarp::os::Bottle objects, you may want to call yarp::os::Bottle::clear(), for example. YARP doesn't clear objects for you, since there are many cases in which overwriting old data is suffient and reallocation of memory would be unnecessary and inefficient.

Returns
the next object that will be written

Definition at line 177 of file BufferedPort.h.

◆ promiseType()

template<class T>
virtual void yarp::os::BufferedPort< T >::promiseType ( const Type typ)
inlinevirtual

Commit the port to a particular type of data.

Parameters
typthe type of data the port will send/receive

Implements yarp::os::Contactable.

Definition at line 383 of file BufferedPort.h.

◆ read()

template<class T>
virtual T* yarp::os::BufferedPort< T >::read ( bool  shouldWait = true)
inlinevirtual

Read a message from the port.

Waits by default. May return YARP_NULLPTR if the port status has changed.

Parameters
shouldWaitfalse if the call should return immediately if no message is available
Returns
a message, or YARP_NULLPTR

Implements yarp::os::TypedReader< T >.

Definition at line 254 of file BufferedPort.h.

◆ release()

template<class T>
virtual void yarp::os::BufferedPort< T >::release ( void *  handle)
inlinevirtual

Return control to YARP of an object previously taken control of with the acquire() method.

Parameters
handlethe pointer returned by acquire() when control of the object was taken by the user.

Implements yarp::os::TypedReader< T >.

Definition at line 368 of file BufferedPort.h.

◆ releaseProperties()

template<class T>
virtual void yarp::os::BufferedPort< T >::releaseProperties ( Property prop)
inlinevirtual

End access unstructured port properties.

Parameters
propthe port property object provided by acquireProperties()

Implements yarp::os::Contactable.

Definition at line 404 of file BufferedPort.h.

◆ removeCallbackLock()

template<class T>
virtual bool yarp::os::BufferedPort< T >::removeCallbackLock ( )
inlinevirtual

Remove a lock on callbacks added with setCallbackLock()

Implements yarp::os::Contactable.

Definition at line 416 of file BufferedPort.h.

◆ resetReporter()

template<class T>
virtual void yarp::os::BufferedPort< T >::resetReporter ( )
inlinevirtual

Remove the callback which is called upon any future connections and disconnections to/from the port.

Implements yarp::os::Contactable.

Definition at line 358 of file BufferedPort.h.

◆ resume()

template<class T>
virtual void yarp::os::BufferedPort< T >::resume ( )
inlinevirtual

Put the port back in an operative state after interrupt() has been called.

Implements yarp::os::Contactable.

Definition at line 138 of file BufferedPort.h.

◆ setAdminReader()

template<class T>
void yarp::os::BufferedPort< T >::setAdminReader ( PortReader reader)
inlinevirtual

Set an external reader for unrecognized administrative port messages.

Parameters
readerthe external reader to use

Implements yarp::os::Contactable.

Definition at line 284 of file BufferedPort.h.

◆ setCallbackLock()

template<class T>
virtual bool yarp::os::BufferedPort< T >::setCallbackLock ( yarp::os::Mutex mutex)
inlinevirtual

Add a lock to use when invoking callbacks.

mutex.lock() will be called before and mutex.unlock() will be called after the callback. This applies at least to callbacks set by setReader and setAdminReader, and in future may apply to other callbacks.

Parameters
mutexthe lock to use. If YARP_NULLPTR, a mutex will be allocated internally by the port, and destroyed with the port.

Implements yarp::os::Contactable.

Definition at line 412 of file BufferedPort.h.

◆ setEnvelope()

template<class T>
virtual bool yarp::os::BufferedPort< T >::setEnvelope ( PortWriter envelope)
inlinevirtual

Set an envelope (e.g., a timestamp) to the next message which will be sent.

You must be sure to match the type of your envelope for setEnvelope with whatever will be read using getEnvelope. The Stamp class is a typical choice for timestamps. The Bottle class also works as an envelope, but it is not specialized to be efficient.

Currently, for proper operation, the envelope must serialize correctly in text-mode (even if you do not explicitly use text-mode connections). Bottle or Stamp are good choices.

Parameters
envelopeinformation to add to the next message which will be sent
Returns
true iff setting the envelope was successful

Implements yarp::os::Contactable.

Definition at line 322 of file BufferedPort.h.

◆ setInputMode()

template<class T>
virtual void yarp::os::BufferedPort< T >::setInputMode ( bool  expectInput)
inlinevirtual

Configure the port to allow or forbid inputs.

By default, ports allow anything.

Parameters
expectInputset to true if this port will be used for input

Implements yarp::os::Contactable.

Definition at line 387 of file BufferedPort.h.

◆ setOutputMode()

template<class T>
virtual void yarp::os::BufferedPort< T >::setOutputMode ( bool  expectOutput)
inlinevirtual

Configure the port to allow or forbid outputs.

By default, ports allow anything.

Parameters
expectOutputset to true if this port will be used for output

Implements yarp::os::Contactable.

Definition at line 391 of file BufferedPort.h.

◆ setReader()

template<class T>
void yarp::os::BufferedPort< T >::setReader ( PortReader reader)
inlinevirtual

Set an external reader for port data.

Parameters
readerthe external reader to use

Implements yarp::os::Contactable.

Definition at line 279 of file BufferedPort.h.

◆ setReplier()

template<class T>
void yarp::os::BufferedPort< T >::setReplier ( PortReader reader)
inlinevirtual

If a message is received that requires a reply, use this handler.

No buffering happens.

Parameters
readerthe handler to use

Implements yarp::os::TypedReader< T >.

Definition at line 274 of file BufferedPort.h.

◆ setReporter()

template<class T>
virtual void yarp::os::BufferedPort< T >::setReporter ( PortReport reporter)
inlinevirtual

Set a callback to be called upon any future connections and disconnections to/from the port.

To get information on the current connections that exist, use the getReport method instead.

Parameters
reportercallback for port event/state information

Implements yarp::os::Contactable.

Definition at line 353 of file BufferedPort.h.

◆ setRpcMode()

template<class T>
virtual void yarp::os::BufferedPort< T >::setRpcMode ( bool  expectRpc)
inlinevirtual

Configure the port to be RPC only.

By default all ports can be used for RPC or streaming communication.

Parameters
expectRpcset to true if this port will be used for RPC only

Implements yarp::os::Contactable.

Definition at line 395 of file BufferedPort.h.

◆ setStrict()

template<class T>
void yarp::os::BufferedPort< T >::setStrict ( bool  strict = true)
inlinevirtual

Never drop any messages read.

If you can't read them as fast as the come in, watch out.

Implements yarp::os::TypedReader< T >.

Definition at line 240 of file BufferedPort.h.

◆ setTargetPeriod()

template<class T>
virtual void yarp::os::BufferedPort< T >::setTargetPeriod ( double  period)
inlinevirtual

Try to provide data periodically.

If no new data arrives in a given period, repeat the last data received (if any). Similarly, the port should not pass on data more frequently than the given period.

Parameters
periodtarget period in (fractional) seconds.

Implements yarp::os::TypedReader< T >.

Definition at line 374 of file BufferedPort.h.

◆ sharedOpen()

template<class T>
bool yarp::os::BufferedPort< T >::sharedOpen ( Port port)
inlineprivate

Definition at line 458 of file BufferedPort.h.

◆ tryLockCallback()

template<class T>
virtual bool yarp::os::BufferedPort< T >::tryLockCallback ( )
inlinevirtual

Try to lock callbacks until unlockCallback() is called.

Has no effect if no lock has been set via a call to setCallbackLock(). Returns immediately.

Returns
true if callbacks were locked by this call, false if they were already locked.

Implements yarp::os::Contactable.

Definition at line 424 of file BufferedPort.h.

◆ unlockCallback()

template<class T>
virtual void yarp::os::BufferedPort< T >::unlockCallback ( )
inlinevirtual

Unlock callbacks.

Implements yarp::os::Contactable.

Definition at line 428 of file BufferedPort.h.

◆ unprepare()

template<class T>
bool yarp::os::BufferedPort< T >::unprepare ( )
inline

Give the last prepared object back to YARP without writing it.

Returns
true if there was a prepared object to return.

Definition at line 189 of file BufferedPort.h.

◆ useCallback() [1/2]

template<class T>
void yarp::os::BufferedPort< T >::useCallback ( TypedReaderCallback< T > &  callback)
inlinevirtual

Set an object whose onRead method will be called when data is available.

Implements yarp::os::TypedReader< T >.

Definition at line 302 of file BufferedPort.h.

◆ useCallback() [2/2]

template<class T>
void yarp::os::BufferedPort< T >::useCallback ( )
inline

Call own onRead() method – user can override that method to be informed about data as it arrives.

Definition at line 311 of file BufferedPort.h.

◆ waitForWrite()

template<class T>
void yarp::os::BufferedPort< T >::waitForWrite ( )
inline

Wait for any pending writes to complete.

Definition at line 230 of file BufferedPort.h.

◆ where()

template<class T>
virtual Contact yarp::os::BufferedPort< T >::where ( ) const
inlinevirtual

Returns information about how this port can be reached.

Returns
network parameters for this port

Implements yarp::os::Contactable.

Definition at line 151 of file BufferedPort.h.

◆ write()

template<class T>
void yarp::os::BufferedPort< T >::write ( bool  forceStrict = false)
inline

Write the current object being returned by BufferedPort::prepare.

That object should no longer be touched by the user of this class – it is now owned by the communications system. The BufferedPort::prepare method should be called again to get a fresh (or reused) object guaranteed to be not in use by the communications system.

Parameters
forceStrictIf this is true, wait until any previous sends are complete. If false, the current object will not be sent on connections that are currently busy.

Definition at line 204 of file BufferedPort.h.

◆ writeStrict()

template<class T>
void yarp::os::BufferedPort< T >::writeStrict ( )
inline

Write the current object being returned by BufferedPort::prepare, waiting until any previous sends are complete.

That object should no longer be touched by the user of this class – it is now owned by the communications system. The BufferedPort::prepare method should be called again to get a fresh (or reused) object guaranteed to be not in use by the communications system.

Definition at line 221 of file BufferedPort.h.

Member Data Documentation

◆ attached

template<class T>
bool yarp::os::BufferedPort< T >::attached
private

Definition at line 437 of file BufferedPort.h.

◆ interrupted

template<class T>
bool yarp::os::BufferedPort< T >::interrupted
private

Definition at line 436 of file BufferedPort.h.

◆ port

template<class T>
Port yarp::os::BufferedPort< T >::port
private

Definition at line 434 of file BufferedPort.h.

◆ reader

template<class T>
PortReaderBuffer<T> yarp::os::BufferedPort< T >::reader
private

Definition at line 435 of file BufferedPort.h.

◆ writer

template<class T>
PortWriterBuffer<T> yarp::os::BufferedPort< T >::writer
private

Definition at line 433 of file BufferedPort.h.


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