YARP  2.3.70.1
Yet Another Robot Platform
yarp::os::TypedReader< T > Class Template Referenceabstract

A base class for sources of typed data. More...

#include <yarp/os/PortReaderBuffer.h>

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

Public Member Functions

virtual void setStrict (bool strict=true)=0
 Call this to strictly keep all messages, or allow old ones to be quietly dropped. More...
 
virtual T * read (bool shouldWait=true)=0
 Read an available object from the port. More...
 
virtual void interrupt ()=0
 Abort any read operation currently in progress. More...
 
virtual T * lastRead ()=0
 Get the last data returned by read() More...
 
virtual bool isClosed ()=0
 
virtual void useCallback (TypedReaderCallback< T > &callback)=0
 Set an object whose onRead method will be called when data is available. More...
 
virtual void disableCallback ()=0
 Remove a callback set up with useCallback() More...
 
virtual int getPendingReads ()=0
 Check how many messages are waiting to be read. More...
 
virtual ~TypedReader ()
 Destructor. More...
 
virtual ConstString getName () const =0
 Get name of port being read from. More...
 
virtual void setReplier (PortReader &reader)=0
 If a message is received that requires a reply, use this handler. More...
 
virtual void * acquire ()=0
 Take control of the last object read. More...
 
virtual void release (void *handle)=0
 Return control to YARP of an object previously taken control of with the acquire() method. More...
 
virtual void setTargetPeriod (double period)=0
 Try to provide data periodically. More...
 

Detailed Description

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

A base class for sources of typed data.

This could be a BufferedPort or a PortReaderBuffer.

Definition at line 23 of file PortReaderBuffer.h.

Constructor & Destructor Documentation

◆ ~TypedReader()

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

Destructor.

Definition at line 147 of file PortReaderBuffer.h.

Member Function Documentation

◆ acquire()

template<class T>
virtual void* yarp::os::TypedReader< T >::acquire ( )
pure virtual

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.

Implemented in yarp::os::PortReaderBuffer< T >, yarp::os::PortReaderBuffer< Bottle >, yarp::os::PortReaderBuffer< yarp::sig::Vector >, yarp::os::PortReaderBuffer< ImageType >, yarp::os::PortReaderBuffer< yarp::sig::ImageOf< yarp::sig::PixelFloat > >, yarp::os::PortReaderBuffer< yarp::os::Bottle >, yarp::os::PortReaderBuffer< ImageOf< PixelInt > >, yarp::os::PortReaderBuffer< yarp::sig::ImageOf< yarp::sig::PixelRgb > >, yarp::os::PortReaderBuffer< yarp::sig::ImageOf< yarp::sig::PixelInt > >, yarp::os::PortReaderBuffer< yarp::sig::FlexImage >, yarp::os::PortReaderBuffer< yarp::sig::ImageOf< yarp::sig::PixelMono16 > >, yarp::os::BufferedPort< T >, yarp::os::BufferedPort< Bottle >, yarp::os::BufferedPort< yarp::sig::Vector >, yarp::os::BufferedPort< ImageType >, yarp::os::BufferedPort< yarp::sig::ImageOf< yarp::sig::PixelFloat > >, yarp::os::BufferedPort< yarp::os::Bottle >, yarp::os::BufferedPort< ImageOf< PixelInt > >, yarp::os::BufferedPort< yarp::sig::ImageOf< yarp::sig::PixelRgb > >, yarp::os::BufferedPort< yarp::sig::ImageOf< yarp::sig::PixelInt > >, yarp::os::BufferedPort< yarp::sig::FlexImage >, and yarp::os::BufferedPort< yarp::sig::ImageOf< yarp::sig::PixelMono16 > >.

◆ disableCallback()

◆ getName()

◆ getPendingReads()

◆ interrupt()

◆ isClosed()

◆ lastRead()

◆ read()

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

Read an available object from the port.

Parameters
shouldWaittrue if the method should wait until an object is available
Returns
A pointer to an object read from the port, or YARP_NULLPTR if none is available and waiting was not requested. This object is owned by the communication system and should not be deleted by the user. The object is available to the user until the next call to one of the read methods, after which it should not be accessed again.

Implemented in yarp::os::PortReaderBuffer< T >, yarp::os::PortReaderBuffer< Bottle >, yarp::os::PortReaderBuffer< yarp::sig::Vector >, yarp::os::PortReaderBuffer< ImageType >, yarp::os::PortReaderBuffer< yarp::sig::ImageOf< yarp::sig::PixelFloat > >, yarp::os::PortReaderBuffer< yarp::os::Bottle >, yarp::os::PortReaderBuffer< ImageOf< PixelInt > >, yarp::os::PortReaderBuffer< yarp::sig::ImageOf< yarp::sig::PixelRgb > >, yarp::os::PortReaderBuffer< yarp::sig::ImageOf< yarp::sig::PixelInt > >, yarp::os::PortReaderBuffer< yarp::sig::FlexImage >, yarp::os::PortReaderBuffer< yarp::sig::ImageOf< yarp::sig::PixelMono16 > >, yarp::os::BufferedPort< T >, yarp::os::BufferedPort< Bottle >, yarp::os::BufferedPort< yarp::sig::Vector >, yarp::os::BufferedPort< ImageType >, yarp::os::BufferedPort< yarp::sig::ImageOf< yarp::sig::PixelFloat > >, yarp::os::BufferedPort< yarp::os::Bottle >, yarp::os::BufferedPort< ImageOf< PixelInt > >, yarp::os::BufferedPort< yarp::sig::ImageOf< yarp::sig::PixelRgb > >, yarp::os::BufferedPort< yarp::sig::ImageOf< yarp::sig::PixelInt > >, yarp::os::BufferedPort< yarp::sig::FlexImage >, and yarp::os::BufferedPort< yarp::sig::ImageOf< yarp::sig::PixelMono16 > >.

◆ release()

◆ setReplier()

◆ setStrict()

template<class T>
virtual void yarp::os::TypedReader< T >::setStrict ( bool  strict = true)
pure virtual

◆ setTargetPeriod()

template<class T>
virtual void yarp::os::TypedReader< T >::setTargetPeriod ( double  period)
pure virtual

◆ useCallback()


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