Robot Raconteur Companion C++ Library
Loading...
Searching...
No Matches
RobotRaconteur::Companion::Util::SyncTaskGenerator< StatusType > Class Template Referenceabstract

A template class for generating synchronous tasks. More...

#include <TaskGenerator.h>

Inheritance diagram for RobotRaconteur::Companion::Util::SyncTaskGenerator< StatusType >:
RobotRaconteur::Companion::Util::AsyncTaskGenerator< StatusType >

Public Member Functions

 SyncTaskGenerator (boost::shared_ptr< RobotRaconteur::RobotRaconteurNode > node, int32_t next_timeout, int32_t watchdog_timeout)
 Constructor for SyncTaskGenerator.

Protected Member Functions

virtual boost::intrusive_ptr< StatusType > RunTask ()=0
 Pure virtual function to be implemented by the user.
RR_OVIRTUAL void StartTask () RR_OVERRIDE
 Start the task.
virtual void SetResult (boost::intrusive_ptr< StatusType > &result)
 Set the result of the generator.
virtual void SetResultException (boost::shared_ptr< RobotRaconteur::RobotRaconteurException > &exp)
 Set the exception result of the generator.
void SendUpdate ()
 Send an update to the caller.
virtual void CloseRequested ()
 This method is called when a close request is received.
virtual void AbortRequested ()
 This method is called when an abort request is received.
virtual void FillStatus (boost::intrusive_ptr< StatusType > &status)
 This method is called to fill the next status report.

Detailed Description

template<typename StatusType>
class RobotRaconteur::Companion::Util::SyncTaskGenerator< StatusType >

A template class for generating synchronous tasks.

This class is derived from the AsyncTaskGenerator class and provides a framework for generating synchronous tasks. It allows the user to define a RunTask() function that performs the actual task and returns a result of type StatusType. The task is executed in a separate thread and the result is set using the SetResult() function. If an exception occurs during task execution, it is caught and converted to a RobotRaconteurException, which is then set as the result exception.

The user should override the RunTask() function to perform the actual task. The StartTask(), SetResult(), and SetResultException() functions should not be called by the user.

Template Parameters
StatusTypeThe type of the task result.

Constructor & Destructor Documentation

◆ SyncTaskGenerator()

template<typename StatusType>
RobotRaconteur::Companion::Util::SyncTaskGenerator< StatusType >::SyncTaskGenerator ( boost::shared_ptr< RobotRaconteur::RobotRaconteurNode > node,
int32_t next_timeout,
int32_t watchdog_timeout )
inline

Constructor for SyncTaskGenerator.

Parameters
nodeThe RobotRaconteurNode instance.
next_timeoutThe timeout to return from the Next() function.
watchdog_timeoutThe timeout for the watchdog. -1 to disable.

Member Function Documentation

◆ FillStatus()

template<typename StatusType>
virtual void RobotRaconteur::Companion::Util::AsyncTaskGenerator< StatusType >::FillStatus ( boost::intrusive_ptr< StatusType > & status)
inlineprotectedvirtualinherited

This method is called to fill the next status report.

This method is called to fill the next status report. Subclasses should override this method to fill the next status report.

Parameters
statusThe status report to fill

◆ RunTask()

template<typename StatusType>
virtual boost::intrusive_ptr< StatusType > RobotRaconteur::Companion::Util::SyncTaskGenerator< StatusType >::RunTask ( )
protectedpure virtual

Pure virtual function to be implemented by the user.

This function should perform the actual task and return a result of type StatusType.

Returns
RR_INTRUSIVE_PTR<StatusType> The result of the task.

◆ SendUpdate()

template<typename StatusType>
void RobotRaconteur::Companion::Util::AsyncTaskGenerator< StatusType >::SendUpdate ( )
inlineprotectedinherited

Send an update to the caller.

This method triggers Next() to return an intermediate status report. Override FillStatus() to fill the status report.

◆ SetResult()

template<typename StatusType>
virtual void RobotRaconteur::Companion::Util::AsyncTaskGenerator< StatusType >::SetResult ( boost::intrusive_ptr< StatusType > & result)
inlineprotectedvirtualinherited

Set the result of the generator.

This method sets the result of the generator. The generator will return the result to the caller.

Parameters
resultThe result to return

◆ SetResultException()

template<typename StatusType>
virtual void RobotRaconteur::Companion::Util::AsyncTaskGenerator< StatusType >::SetResultException ( boost::shared_ptr< RobotRaconteur::RobotRaconteurException > & exp)
inlineprotectedvirtualinherited

Set the exception result of the generator.

This method sets the exception result of the generator. The generator will return the exception to the caller.

Parameters
expThe exception to return

◆ StartTask()

template<typename StatusType>
RR_OVIRTUAL void RobotRaconteur::Companion::Util::SyncTaskGenerator< StatusType >::StartTask ( )
inlineprotectedvirtual

Start the task.

This method is called when the generator is started. Subclasses should override this method to start the task.

Implements RobotRaconteur::Companion::Util::AsyncTaskGenerator< StatusType >.


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