AAO DRAMA/DRAMA2 C++ Interface
DRAMA C++11 and later interface
entryinfo.hh
Go to the documentation of this file.
1#ifndef _DRAMA2_ENTRYINFO_INC
2#define _DRAMA2_ENTRYINFO_INC
3
19/*
20 * History:
21 09-Jan-2014 - TJF - Original version
22
23 * The above ID is for Doxygen, this one has the format ACMM is looking for.
24 * "@(#) $Id$"
25 */
26
27
28#include "DitsSystem.h"
29#include "DitsInteraction.h" /* For DitsTaskFromPath */
30#include "drama/sds.hh"
31
32namespace drama {
33
40 enum class EntryCode {
41 /*
42 * Entry codes equivalent to DRAMA Entry reasons.
43 */
65 /*
66 * Extra entry codes used internally
67 * 1111 is well out of the range used by the DRAMA entry
68 * reasons, so that is our base.
69 */
70
71 DramaRunLoopExit=1111, // Task::RunDrama exited returned.
72 DramaMainThreadComplete=1112, // Action thread completed.
73 DramaAbortWaits=1113 // Intentional abort of waits.
74 };
75
79 class EntryInfo {
80 private:
82 unsigned long _sequence=0;
83 long _actionPtr=-1;
84 DitsPathType _path = nullptr;
85
86 public:
89 EntryInfo() {}
90
96 void SetFromDits() {
97 /*
98 * Note- does not handle DYNAMIC allocation of DITS Global
99 * data, but that only happens on VxWorks and we don't support
100 * VxWorks. Should get a compiler error here in such cases, but
101 * we force is by ensuring
102 */
103#ifdef DITS_TASKDYNAMIC
104 static_assert(0, "DRAMA 2 does not (yet) support dynamic DITS Global items");
105#endif
106 _info = DitsCurrent.Mess;
107 _actionPtr = DitsCurrent.actionptr;
108 if (_actionPtr >= 0)
109 _sequence = DitsActions[DitsCurrent.actionptr].seq;
110 else
111 _sequence = 0;
112
113 _path = DitsGetEntPath();
114 }
115
120 sds::Id Argument() const {
121 return sds::Id::CreateFromSdsIdType(_info.argin);
122 }
130 StatusType Status() const {
131 return _info.reasonstat;
132 }
137 EntryCode Reason() const {
138 return static_cast<EntryCode>(_info.reason);
139 }
140
145 std::string EntryName() const {
146 return _info.name.n;
153 bool Complete() const {
154 return static_cast<bool>(_info.complete);
155 }
168 std::string LoadErrText() const {
169 if ((Reason() == EntryCode::LoadFailed)||
171 return _info.sysErrText;
172 else
173 return "";
174 }
188 long int LoadErrorStatus() const {
189 return _info.sysSysStat;
190 }
191
197 return (DitsTransIdType)(_info.transid);
198 }
203 unsigned long Sequence() const {
204 return _sequence;
205 }
222 return _info.bulkTransferInfo;
224
231 return _path;
232 }
238 std::string EntryTaskName() const {
239 if (_path)
240 {
244 if (status == STATUS__OK)
245 return taskname;
246 DramaTHROW(status, "Failure getting task name for entry path");
247 }
248 return "";
249 }
250
260 bool ArgIsBulk() const {
261 return _info.bulkArgRelease ? true : false;
262 }
263
264 };
266} // namespace drama
267
268#endif
long int LoadErrorStatus() const
Returns the system status code associated with a load error.
Definition entryinfo.hh:215
DitsBulkInfoType GetBulkInfo() const
Return bulk transfer info.
Definition entryinfo.hh:248
std::string EntryName() const
Return the name associated with the entry.
Definition entryinfo.hh:172
std::string LoadErrText() const
Returns the system status code text associated with a load error.
Definition entryinfo.hh:195
sds::Id Argument() const
Return any SDS argument to the action entry.
Definition entryinfo.hh:147
DitsTransIdType EntryTransId() const
Return the transaction id associated with the entry.
Definition entryinfo.hh:223
unsigned long Sequence() const
Return the Action sequence count.
Definition entryinfo.hh:230
EntryInfo()
Construct the EntryInfo item.
Definition entryinfo.hh:116
bool ArgIsBulk() const
Indicates if the action argument was transferred using bulk data techniques.
Definition entryinfo.hh:287
bool Complete() const
Indicate if any transaction associated with this entry is complete.
Definition entryinfo.hh:180
StatusType Status() const
Return the status associated with the action entry.
Definition entryinfo.hh:157
void SetFromDits()
Grab the information of interest from DITS.
Definition entryinfo.hh:123
EntryCode Reason() const
Return the reason associated with the action entry.
Definition entryinfo.hh:164
DitsPathType EntryPath() const
Returns the path associated with the current action entry, if any.
Definition entryinfo.hh:257
std::string EntryTaskName() const
Returns the task name of the path associated with the action entry, if any.
Definition entryinfo.hh:265
The EntryInfo class is used to access details about a DRAMA message event (and entry to an action).
Definition entryinfo.hh:106
static Id CreateFromSdsIdType(const SdsIdType item, const bool free=false, const bool del=false, const bool readfree=false)
Factory constructor method that constructs an sds::Id item from an existing C language SDS id.
A C++ Interface to the handling SDS structures.
Definition sds.hh:428
#define DramaTHROW(status_, message_)
Throw a Drama exception.
Definition exception.hh:93
void CreateRunDramaTask()
Create and run a DRAMA task, with standard exception handling.
Definition task.hh:1322
EntryCode
Entry type code - indicates the type of a DRAMA event.
Definition entryinfo.hh:67
@ Resched
Action reschedule reschedule - aliased by Timeout.
@ Signal
Signal message received.
@ LoadFailed
Attempt to load a program failed.
@ Kick
Action has been kicked.
@ Message
MsgOut message from subsidiary action.
@ BulkTransferred
bulk data transferred message received
@ PathFound
GetPath operation success.
@ BulkDone
message received
@ Error
ERS Message from subsidiary action.
@ PathFailed
GetPath operation failed.
@ Obey
Action has been obeyed.
@ Notify
DRAMA notification message received.
@ Complete
Obey/Kick etc message completed.
@ Died
Task we have a path to has died.
@ Timeout
Action reschedule reschedule - alias to Resched.
@ Rejected
Obey/Kick etc message rejected.
@ Load
Load successful, task registered.
@ Trigger
Trigger message from subsidiary action.
@ Drama2Signal
message received
@ Exit
Loaded task exited message received.
The drama namespace contains all the classes, types etc of the DRAMA 2 implementation.
Definition drama.hh:93
DRAMA 2 include file - Sds class definition.