DDS  ver. 3.6
Public Types | Public Member Functions | Protected Member Functions | List of all members
dds::intercom_api::CRMSPluginProtocol Class Reference

Class implements basic API for DDS RMS plug-ins. More...

#include <Intercom.h>

Public Types

typedef boost::signals2::signal< void(const SSubmit &)> signalSubmit_t
 Callback function for submit notifications. More...
 
typedef boost::signals2::signal< void(const SMessage &)> signalMessage_t
 Callback function for message notifications. More...
 

Public Member Functions

 CRMSPluginProtocol (const std::string &_id)
 Constructor with ID. More...
 
 ~CRMSPluginProtocol ()
 Destructor. More...
 
void onSubmit (signalSubmit_t::slot_function_type _subscriber)
 Subscribe for submit notifications. More...
 
void onMessage (signalMessage_t::slot_function_type _subscriber)
 Subscribe for message notifications. More...
 
void sendMessage (EMsgSeverity _severity, const std::string &_msg)
 Send message to DDS commander. More...
 
void start (bool _block=true)
 Send initial request to the commander and start listening for notifications. More...
 
void stop ()
 Stop waiting. More...
 

Protected Member Functions

void notify (std::istream &_stream)
 Parse the input stream and notify subscribers. More...
 

Detailed Description

Class implements basic API for DDS RMS plug-ins.

Example Usage:

try {
CRMSPluginProtocol prot("plug-in-id");
prot.onSubmit([](const SSubmit& _submit) {
// Implement submit related functionality here.
// After submit has completed call stop() function.
prot.stop();
});
prot.onMessage([](const SMessage& _message) {
// Message from commander received.
// Implement related functionality here.
});
// Let DDS commander know that we are online and wait for notifications from commander
prot.start();
} catch (exception& _e) {
// Report error to DDS commander
proto.sendMessage(dds::EMsgSeverity::error, e.what());
}

Member Typedef Documentation

◆ signalMessage_t

typedef boost::signals2::signal<void(const SMessage&)> dds::intercom_api::CRMSPluginProtocol::signalMessage_t

Callback function for message notifications.

◆ signalSubmit_t

typedef boost::signals2::signal<void(const SSubmit&)> dds::intercom_api::CRMSPluginProtocol::signalSubmit_t

Callback function for submit notifications.

Constructor & Destructor Documentation

◆ CRMSPluginProtocol()

CRMSPluginProtocol::CRMSPluginProtocol ( const std::string &  _id)

Constructor with ID.

Parameters
[in]_idDDS commander provides an ID which has to be used for the communication.

◆ ~CRMSPluginProtocol()

CRMSPluginProtocol::~CRMSPluginProtocol ( )

Destructor.

Member Function Documentation

◆ notify()

void CRMSPluginProtocol::notify ( std::istream &  _stream)
protected

Parse the input stream and notify subscribers.

Parameters
[in]_streamStream with JSON data from DDS commander.

◆ onMessage()

void CRMSPluginProtocol::onMessage ( signalMessage_t::slot_function_type  _subscriber)

Subscribe for message notifications.

Parameters
[in]_subscriberCallback function that is called when notification arrives.

◆ onSubmit()

void CRMSPluginProtocol::onSubmit ( signalSubmit_t::slot_function_type  _subscriber)

Subscribe for submit notifications.

Parameters
[in]_subscriberCallback function that is called when notification arrives.

◆ sendMessage()

void CRMSPluginProtocol::sendMessage ( EMsgSeverity  _severity,
const std::string &  _msg 
)

Send message to DDS commander.

Parameters
[in]_severityMessage severity.
[in]_msgMessage text.

◆ start()

void CRMSPluginProtocol::start ( bool  _block = true)

Send initial request to the commander and start listening for notifications.

param[in] _block If true than we stop the main thread.

If _block is true function stops the thread and waits until one of the conditions is applied:

  1. 10 minutes timeout;
  2. Failed connection to DDS commander or disconnection from DDS commander;
  3. Explicit call of stop() function.
Note
If there are no subscribers function doesn't wait.

◆ stop()

void CRMSPluginProtocol::stop ( )

Stop waiting.


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