YARP
Yet Another Robot Platform
yarp::dev::DeviceResponder Class Reference

A cheap and cheerful framework for human readable/writable forms of messages to devices. More...

#include <yarp/dev/DeviceDriver.h>

+ Inheritance diagram for yarp::dev::DeviceResponder:

Public Member Functions

 DeviceResponder ()
 Constructor. More...
 
void addUsage (const char *txt, const char *explain=nullptr)
 Add information about a message that the respond() method understands. More...
 
void addUsage (const yarp::os::Bottle &bot, const char *explain=nullptr)
 Add information about a message that the respond() method understands. More...
 
virtual bool respond (const yarp::os::Bottle &command, yarp::os::Bottle &reply)
 Respond to a message. More...
 
bool read (yarp::os::ConnectionReader &connection) override
 Handler for reading messages from the network, and passing them on to the respond() method. More...
 
void onRead (yarp::os::Bottle &v) override
 Alternative handler for reading messages from the network, and passing them on to the respond() method. More...
 
void makeUsage ()
 Regenerate usage information. More...
 
void attach (yarp::os::TypedReader< yarp::os::Bottle > &source)
 Attach this object to a source of messages. More...
 
- Public Member Functions inherited from yarp::os::PortReader
virtual ~PortReader ()
 Destructor. More...
 
virtual bool read (ConnectionReader &reader)=0
 Read this object from a network connection. More...
 
virtual Type getReadType () const
 
- Public Member Functions inherited from yarp::os::TypedReaderCallback< yarp::os::Bottle >
virtual ~TypedReaderCallback ()
 Destructor. More...
 
virtual void onRead (yarp::os::Bottle &datum)
 Callback method. More...
 
virtual void onRead (yarp::os::Bottle &datum, const yarp::os::TypedReader< yarp::os::Bottle > &reader)
 Callback method. More...
 

Detailed Description

A cheap and cheerful framework for human readable/writable forms of messages to devices.

The main concern is to makes it easier to document these messages. Override DeviceResponder::respond() to respond to new messages. You don't need to use this class – the network format of messages is defined independently of it.

Definition at line 149 of file DeviceDriver.h.

Constructor & Destructor Documentation

◆ DeviceResponder()

DeviceResponder::DeviceResponder ( )

Constructor.

Definition at line 48 of file DeviceDriver.cpp.

Member Function Documentation

◆ addUsage() [1/2]

void DeviceResponder::addUsage ( const char *  txt,
const char *  explain = nullptr 
)

Add information about a message that the respond() method understands.

Parameters
txtthe message, in text form
explainan (optional) what the message means

Definition at line 52 of file DeviceDriver.cpp.

◆ addUsage() [2/2]

void DeviceResponder::addUsage ( const yarp::os::Bottle bot,
const char *  explain = nullptr 
)

Add information about a message that the respond() method understands.

Parameters
botthe message, in bottle form
explainan (optional) what the message means

Definition at line 61 of file DeviceDriver.cpp.

◆ attach()

void yarp::dev::DeviceResponder::attach ( yarp::os::TypedReader< yarp::os::Bottle > &  source)
inline

Attach this object to a source of messages.

Parameters
sourcea BufferedPort or PortReaderBuffer that receives data.

Definition at line 219 of file DeviceDriver.h.

◆ makeUsage()

void DeviceResponder::makeUsage ( )

Regenerate usage information.

Definition at line 130 of file DeviceDriver.cpp.

◆ onRead()

void yarp::dev::DeviceResponder::onRead ( yarp::os::Bottle v)
inlineoverridevirtual

Alternative handler for reading messages from the network, and passing them on to the respond() method.

There can be no replies made if this handler is used.

Parameters
vthe message

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

Definition at line 204 of file DeviceDriver.h.

◆ read()

bool DeviceResponder::read ( yarp::os::ConnectionReader connection)
overridevirtual

Handler for reading messages from the network, and passing them on to the respond() method.

Parameters
connectiona network connection to a port
Returns
true if the message was read successfully

Implements yarp::os::PortReader.

Definition at line 89 of file DeviceDriver.cpp.

◆ respond()


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