AAO DRAMA/DRAMA2 C++ Interface
DRAMA C++11 and later interface
spawnable.hh
Go to the documentation of this file.
1#ifndef _DRAMA2_SPAWNABLE_INC
2#define _DRAMA2_SPAWNABLE_INC
18/*
19 * History:
20 07-Jan-2014 - TJF - Original version
21
22 * The above ID is for Doxygen, this one has the format ACMM is looking for.
23 * "@(#) $Id$"
24*/
25#include "drama/task.hh"
26#include "drama/entryinfo.hh"
27#include "drama/request.hh"
28#include "drama/action.hh"
30#include "status.h"
31namespace drama {
32
57 class Spawnable : public ActionHandler {
58 private:
59
60 // *************
61 // Override of three methods from ActionHandler
62 /*
63 * MessageEvent is invoked when a message is received. Must invoke
64 * the sub-class's method.
65 */
66 Request MessageEvent(std::weak_ptr<Task> task, Action *action)
67 override final;
68 /* This is invoked when the action ends.
69 *
70 * Will never be invoked as control is passed to a user's MessageHandler
71 * which is what is invoked.
72 */
73 void InvokeActionEnd(std::weak_ptr<Task> task, Action *action,
74 bool taskExiting,
75 StatusType actionEndStatus) override final;
76 /* Invoked when DITS is cleaning up an action's entry in the internal
77 * DITS tables.
78 *
79 * This method should return true if the internal objects related
80 * to this action can be deleted.
81 */
82
83 /* This three are only valid during a call to MessageReceived() . */
84 std::weak_ptr<Task> _theTask;
85
86 public:
87
94 Spawnable() { }
95
100 virtual ~Spawnable();
101
106 Spawnable& operator=(const Spawnable &rhs) = delete;
111 Spawnable(const Spawnable &source) = delete;
112
118 Spawnable& operator=( Spawnable &&rhs) = default;
123 Spawnable( Spawnable &&source) = default;
124 private:
125#ifdef RUNNING_DOXYGEN /* So that DOXYGEN will document the next one */
126 protected:
127#endif
137 virtual MessageHandlerPtr Spawn() = 0;
138 public:
153 virtual void ActionEnd(MessageHandlerPtr obj) = 0;
154
160 virtual std::shared_ptr<Task> GetTask() const {
161 return std::shared_ptr<Task>(_theTask);
162 }
163
164 protected:
165
166 }; // class Spawnable.
167
173 using SpawnablePtr = std::shared_ptr<Spawnable> ;
174
175
176
177} // namespace drama
178
179#endif
Class used by Obey and Kick handlers to indicate rescheduling requirements.
Definition request.hh:78
virtual MessageHandlerPtr Spawn()=0
An Action has been spawned, return a handler for the message.
virtual ~Spawnable()
Spawnable destructor.
Spawnable & operator=(Spawnable &&rhs)=default
Move operator.
Spawnable & operator=(const Spawnable &rhs)=delete
Copy operator deleted.
virtual std::shared_ptr< Task > GetTask() const
Returns a pointer to the task.
Definition spawnable.hh:187
Spawnable(Spawnable &&source)=default
Move assignment operator.
virtual void ActionEnd(MessageHandlerPtr obj)=0
Invoked when the spawned action has completed.
Spawnable(const Spawnable &source)=delete
Assignment operator deleted.
Spawnable()
Create a DRAMA spawnable action action handler object.
Definition spawnable.hh:121
A class which implements a Spawnable DRAMA Message Handler.
Definition spawnable.hh:84
DRAMA 2 include file - implements a class providing access to details on an action entry.
DRAMA 2 include file - Message Handler class definition.
void CreateRunDramaTask()
Create and run a DRAMA task, with standard exception handling.
Definition task.hh:1322
std::shared_ptr< Spawnable > SpawnablePtr
This type is used for passing Spawnable object addresses around.
Definition spawnable.hh:200
std::shared_ptr< MessageHandler > MessageHandlerPtr
This type is used for passing MessageHandler object addresses around.
Definition messagehandler.hh:101
The drama namespace contains all the classes, types etc of the DRAMA 2 implementation.
Definition drama.hh:93
DRAMA 2 include file - Request class definition.
DRAMA 2 include file - Task class definition.