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 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 132 of file DeviceDriver.h.

Constructor & Destructor Documentation

◆ DeviceResponder()

DeviceResponder::DeviceResponder ( )

Constructor.

Definition at line 21 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 25 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 34 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 202 of file DeviceDriver.h.

◆ makeUsage()

void DeviceResponder::makeUsage ( )

Regenerate usage information.

Definition at line 99 of file DeviceDriver.cpp.

◆ onRead()

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

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

Definition at line 187 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 62 of file DeviceDriver.cpp.

◆ respond()

bool DeviceResponder::respond ( const yarp::os::Bottle command,
yarp::os::Bottle reply 
)
virtual

Respond to a message.

Parameters
commandthe message
replythe response
Returns
true if there was no critical failure

Reimplemented in ServerGrabberResponder, ServerFrameGrabber, yarp::dev::Implement_DepthVisualParams_Parser, yarp::dev::Implement_RgbVisualParams_Parser, yarp::dev::FrameGrabberControls_Parser, DC1394Parser, RGBDImpl::RGBDSensorParser, JoypadCtrlParser, and RPCMessagesParser.

Definition at line 39 of file DeviceDriver.cpp.


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