|
Robot Raconteur Companion C++ Library
|
A template class for generating synchronous tasks. More...
#include <TaskGenerator.h>
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. | |
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.
| StatusType | The type of the task result. |
|
inline |
Constructor for SyncTaskGenerator.
| node | The RobotRaconteurNode instance. |
| next_timeout | The timeout to return from the Next() function. |
| watchdog_timeout | The timeout for the watchdog. -1 to disable. |
|
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.
| status | The status report to fill |
|
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.
|
inlineprotectedinherited |
Send an update to the caller.
This method triggers Next() to return an intermediate status report. Override FillStatus() to fill the status report.
|
inlineprotectedvirtualinherited |
Set the result of the generator.
This method sets the result of the generator. The generator will return the result to the caller.
| result | The result to return |
|
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.
| exp | The exception to return |
|
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 >.