Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
industrial::message_handler::MessageHandler Class Referenceabstract

Interface definition for message handlers. The interface defines the callback function that should execute when a message is received. More...

#include <message_handler.h>

Inheritance diagram for industrial::message_handler::MessageHandler:
Inheritance graph
[legend]

Public Member Functions

bool callback (industrial::simple_message::SimpleMessage &in)
 Callback function that should be executed when a message arrives DO NOT OVERRIDE THIS FUNCTION. It performs message validation before the internal callback (which should be overridden) is called. If one is required the callback sends a message reply. More...
 
int getMsgType ()
 Gets message type that callback expects. More...
 
 MessageHandler ()
 Constructor. More...
 
 ~MessageHandler ()
 Destructor. More...
 

Protected Member Functions

industrial::smpl_msg_connection::SmplMsgConnectiongetConnection ()
 Gets connectoin for message replies. More...
 
bool init (int msg_type, industrial::smpl_msg_connection::SmplMsgConnection *connection)
 Class initializer. More...
 

Private Member Functions

virtual bool internalCB (industrial::simple_message::SimpleMessage &in)=0
 Virtual callback function. More...
 
void setConnection (industrial::smpl_msg_connection::SmplMsgConnection *connection)
 Sets connection for message replies. More...
 
void setMsgType (int msg_type)
 Sets message type that callback expects. More...
 
bool validateMsg (industrial::simple_message::SimpleMessage &in)
 Validates incoming message for processing by internal callback. More...
 

Private Attributes

industrial::smpl_msg_connection::SmplMsgConnectionconnection_
 Reference to reply connection (called if incoming message requires a reply) More...
 
int msg_type_
 Message type expected by callback. More...
 

Detailed Description

Interface definition for message handlers. The interface defines the callback function that should execute when a message is received.

Defines the interface used for function callbacks when a message is received. When used in conjunction with a message_manager (link) generic message handling can be achieved.

THIS CLASS IS NOT THREAD-SAFE

Definition at line 61 of file message_handler.h.

Constructor & Destructor Documentation

◆ MessageHandler()

industrial::message_handler::MessageHandler::MessageHandler ( )

Constructor.

Definition at line 47 of file message_handler.cpp.

◆ ~MessageHandler()

industrial::message_handler::MessageHandler::~MessageHandler ( )

Destructor.

Definition at line 54 of file message_handler.cpp.

Member Function Documentation

◆ callback()

bool industrial::message_handler::MessageHandler::callback ( industrial::simple_message::SimpleMessage in)

Callback function that should be executed when a message arrives DO NOT OVERRIDE THIS FUNCTION. It performs message validation before the internal callback (which should be overridden) is called. If one is required the callback sends a message reply.

Parameters
inincoming message
Returns
true on success, false otherwise

Definition at line 88 of file message_handler.cpp.

◆ getConnection()

industrial::smpl_msg_connection::SmplMsgConnection* industrial::message_handler::MessageHandler::getConnection ( )
inlineprotected

Gets connectoin for message replies.

Returns
connection reference

Definition at line 105 of file message_handler.h.

◆ getMsgType()

int industrial::message_handler::MessageHandler::getMsgType ( )
inline

Gets message type that callback expects.

Returns
message type

Definition at line 93 of file message_handler.h.

◆ init()

bool industrial::message_handler::MessageHandler::init ( int  msg_type,
industrial::smpl_msg_connection::SmplMsgConnection connection 
)
protected

Class initializer.

Parameters
msg_typetype of message expected
connectionsimple message connection that will be used to send replies.
Returns
true on success, false otherwise (an invalid message type)

Definition at line 59 of file message_handler.cpp.

◆ internalCB()

virtual bool industrial::message_handler::MessageHandler::internalCB ( industrial::simple_message::SimpleMessage in)
privatepure virtual

Virtual callback function.

Parameters
inincoming message
Returns
true on success, false otherwise

Implemented in industrial::ping_handler::PingHandler.

◆ setConnection()

void industrial::message_handler::MessageHandler::setConnection ( industrial::smpl_msg_connection::SmplMsgConnection connection)
inlineprivate

Sets connection for message replies.

Parameters
connectionconnection reference

Definition at line 156 of file message_handler.h.

◆ setMsgType()

void industrial::message_handler::MessageHandler::setMsgType ( int  msg_type)
inlineprivate

Sets message type that callback expects.

Parameters
msg_typemessage type

Definition at line 167 of file message_handler.h.

◆ validateMsg()

bool industrial::message_handler::MessageHandler::validateMsg ( industrial::simple_message::SimpleMessage in)
private

Validates incoming message for processing by internal callback.

Parameters
inincoming message
Returns
true on if valid, false otherwise

Definition at line 106 of file message_handler.cpp.

Member Data Documentation

◆ connection_

industrial::smpl_msg_connection::SmplMsgConnection* industrial::message_handler::MessageHandler::connection_
private

Reference to reply connection (called if incoming message requires a reply)

Definition at line 126 of file message_handler.h.

◆ msg_type_

int industrial::message_handler::MessageHandler::msg_type_
private

Message type expected by callback.

Definition at line 131 of file message_handler.h.


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


simple_message
Author(s): Shaun Edwards
autogenerated on Wed Mar 2 2022 00:24:53