AAO DRAMA/DRAMA2 C++ Interface
Public Member Functions | Protected Member Functions | List of all members
drama::Spawnable Class Referenceabstract

Detailed Description

A class which implements a Spawnable DRAMA Message Handler.

Interface only. Users must sub-class and implement Spawn() and End().

In DRAMA, a "spawnable" action is one where then can be multiple action of the same name running at the same time. By default, only one action of given name can be running at one time, but spawnable actions don't have that restriction. They are a little more expensive in terms of performance.

The user implements a sub-class of this interface and provides methods invoked when the action is spawned and when it completes. The Spawn() method is invoked when the action is spawned (an obey message of the specified name is received), and must return a shared pointer to an object to handle the obey message.

These objects can then be supplied to the drama::Task::AddSpawnable() methods to add such an action to the task.

Author
Tony Farrell, AAO
Revision
1.45
Date
22-Feb-2016 14:09:57+11

#include "spawnable.hh"

Inherits drama::ActionHandler.

Public Member Functions

 Spawnable ()
 Create a DRAMA spawnable action action handler object. More...
 
 Spawnable (const Spawnable &source)=delete
 Assignment operator deleted. More...
 
 Spawnable (Spawnable &&source)=default
 Move assignment operator. More...
 
virtual ~Spawnable ()
 Spawnable destructor. More...
 
virtual void ActionEnd (MessageHandlerPtr obj)=0
 Invoked when the spawned action has completed. More...
 
virtual std::shared_ptr< TaskGetTask () const
 Returns a pointer to the task. More...
 
Spawnableoperator= (const Spawnable &rhs)=delete
 Copy operator deleted. More...
 
Spawnableoperator= (Spawnable &&rhs)=default
 Move operator. More...
 

Protected Member Functions

virtual MessageHandlerPtr Spawn ()=0
 An Action has been spawned, return a handler for the message. More...
 

Constructor & Destructor Documentation

drama::Spawnable::Spawnable ( )
inline

Create a DRAMA spawnable action action handler object.

The sub-class Spawn() method will be invoked when the action is spawned, it is the object returned by that which will then be used to handle the message.

virtual drama::Spawnable::~Spawnable ( )
virtual

Spawnable destructor.

This is normally invoked as part of the Task being shutdown.

drama::Spawnable::Spawnable ( const Spawnable source)
delete

Assignment operator deleted.

No copying or assignment of these

drama::Spawnable::Spawnable ( Spawnable &&  source)
default

Move assignment operator.

Member Function Documentation

virtual void drama::Spawnable::ActionEnd ( MessageHandlerPtr  obj)
pure virtual

Invoked when the spawned action has completed.

This method allows any tidying up to be done when the spawned action completes.

Note
- if Spawn() has returned a std::shared_ptr<> to an object that is deleted when the last reference is deleted, then this method does not normally need to do anything. It need only be used if the implementation is doing something else which needs tidying up.
Parameters
objThe object returned by Spawn() for this action.
virtual std::shared_ptr<Task> drama::Spawnable::GetTask ( ) const
inlinevirtual

Returns a pointer to the task.

If we are not in an action or action end handler, then returns nullptr.

Returns
pointer to the task object.
Spawnable& drama::Spawnable::operator= ( const Spawnable rhs)
delete

Copy operator deleted.

No copying or assignment of these

Spawnable& drama::Spawnable::operator= ( Spawnable &&  rhs)
default

Move operator.

virtual MessageHandlerPtr drama::Spawnable::Spawn ( )
protectedpure virtual

An Action has been spawned, return a handler for the message.

This method is invoked each time the action is spawned, that is; each time a message for the action is received.

Returns
A pointer to an object to be used to handle the message. The MessageEvent method of this object will be invoked and can then work as per a normal (non-spawnable) MessageHandler object.

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

Click here for the DRAMA home page and here for the AAO home page.

For more information, contact tjf@aao.gov.au 

Generated on Mon Feb 22 2016 15:57:53 for AAO DRAMA/DRAMA2 C++ Interface by doxygen 1.8.10