TinyRobotics
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | List of all members
CallbackMessageHandler Class Reference

MessageHandler implementation using user-provided callbacks. More...

#include <CallbackMessageHandler.h>

Inheritance diagram for CallbackMessageHandler:
Inheritance graph
[legend]
Collaboration diagram for CallbackMessageHandler:
Collaboration graph
[legend]

Public Types

using ValueCallback = std::function< bool(const Message< float > &, void *)>
 
using CoordinateCallback = std::function< bool(const Message< Coordinate< float > > &, void *)>
 
using GPSCoordinateCallback = std::function< bool(const Message< GPSCoordinate > &, void *)>
 
using MotionStateCallback = std::function< bool(const Message< MotionState3D > &, void *)>
 

Public Member Functions

bool onMessage (const Message< float > &msg) override
 Handle an incoming message (pure virtual).
 
bool onMessage (const Message< Coordinate< float > > &msg) override
 
bool onMessage (const Message< GPSCoordinate > &msg) override
 
bool onMessage (const Message< MotionState3D > &msg) override
 
void setValueCallback (ValueCallback cb, void *reference)
 
void setCoordinateCallback (CoordinateCallback cb, void *reference)
 
void setGPSCoordinateCallback (GPSCoordinateCallback cb, void *reference)
 
void setMotionStateCallback (MotionStateCallback cb, void *reference)
 
virtual bool onMessage (const Message< float > &msg)=0
 Handle an incoming message (pure virtual).
 
virtual bool onMessage (const Message< Coordinate< float > > &msg)
 
virtual bool onMessage (const Message< GPSCoordinate > &msg)
 
virtual bool onMessage (const Message< MotionState3D > &msg)
 

Protected Attributes

void * ref = nullptr
 
ValueCallback valueCallback_
 
CoordinateCallback coordinateCallback_
 
GPSCoordinateCallback gpsCoordinateCallback_
 
MotionStateCallback motionStateCallback_
 

Detailed Description

MessageHandler implementation using user-provided callbacks.

Allows setting custom callbacks for each supported message type.

Member Function Documentation

◆ onMessage() [1/4]

bool onMessage ( const Message< Coordinate< float > > &  msg)
inlineoverridevirtual

Reimplemented from MessageHandler.

◆ onMessage() [2/4]

bool onMessage ( const Message< float > &  msg)
inlineoverridevirtual

Handle an incoming message (pure virtual).

This method should be implemented by derived classes to process messages.

Parameters
msgThe message to handle.
Returns
true if the message was handled successfully, false otherwise.

Implements MessageHandler.

◆ onMessage() [3/4]

bool onMessage ( const Message< GPSCoordinate > &  msg)
inlineoverridevirtual

Reimplemented from MessageHandler.

◆ onMessage() [4/4]

bool onMessage ( const Message< MotionState3D > &  msg)
inlineoverridevirtual

Reimplemented from MessageHandler.


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