AAO DRAMA C++ Interface (Old style)
DRAMA C++, Depreciated, don't use for new code
dcpptask.h
1/*
2 * Name: filter.m4
3 *
4 * Description:
5 * DOXYGEN Input file filter for DRAMA source files.
6 *
7 * This file must be complatible with both Solaris and GNU m4. All
8 * unused macros are deleted and this comment must end up as a C/C++
9 * compatible comment which is not picked up by DOXYGEN.
10 *
11 * Synopsis:
12 * DCF(func) => Produces a link to a DRAMA C source file func.html
13 * in ../routines.
14 * DDL(link,text) => Produce a link to ../link.html, specified link text.
15 *
16 * Language: m4 macro.
17 *
18 * Author: Tony Farrell, AAO.
19 *
20 * "@(#) $Id$"
21 *
22 * History:
23 * 10-Nov-2004 - TJF - Original Version.
24 */
25
26
27
28#ifndef dcpptask_h
29#define dcpptask_h
30/* d c p p t a s k
31
32 * Module name:
33 dcpptask.h
34
35 * Function:
36 A C++ class that provides access to the DRAMA messaging facilities,
37
38 * Description:
39 An object of this class provides an interface allowing you to send
40 messages to other DRAMA tasks.
41
42 This file now uses DOXYGEN comments to generate the C++ web pages.
43 m4 macros of the form @htmlonly <a href="../routines/function.html">function()</a>@endhtmlonly are used in the comments
44 to refer to DRAMA C function documentation (see DramaHtml/Makefile,
45 DramaHtml/doxygen.config and DramaHtml/filter.m4 for details)
46
47 * Language:
48 C++
49
50 * Support: Tony Farrell, AAO
51
52 * Copyright (c) Anglo-Australian Telescope Board, 1995.
53 Not to be used for commercial purposes without AATB permission.
54
55 * @(#) $Id$
56
57 * History:
58 12-Oct-1995 - TJF - Original version. Extracted from dcpp.h
59 09-Nov-1995 - TJF - Change Dits___MsgType to DitsMsgType
60 25-Jun-1997 - TJF - Add the Died() function.
61 26-Jun-1997 - TJF - Add constructor to build SelfPath object.
62 09-Dec-1997 - TJF - Declare class with DPUBLICCLASS to allow
63 export from WIN32 DLL.
64 02-Feb-1998 - TJF - Declare DiscardResponse static function using
65 DSTATICMEM macro to support WIN32 DLL correctly.
66 04-Jun-1998 - TJF - When getting task name for a path which is in
67 SELFINIT state, we get the current task's name.
68 23-Nov-1998 - TJF - Obey and Send have new transid argument, allowing
69 us to Kick spawned actions.
70 22-Dec-1998 - TJF - Add Bulk Data Send function.
71 13-Jan-1998 - TJF - Make message operations Virtual.
72 16-Nov-1999 - TJF - HandleBulkTrans now returns void.
73 Add new versions of the Obey routines which
74 have an SdsId * final argument, these wrap
75 up the use of DitsSpawnKickArg. Also add
76 versions with a "const SdsId *", which wrap up a
77 a call to DitsSpawnKickArgUpdate.
78 19-Nov-1999 - TJF - DitsSharedMemInfoType arguments replaced by
79 DcppShared arguments.
80 12-Sep-2003 - TJF - Add transaction id argument Forget versions of obey
81 (need to create new versions). This allows us to
82 Forget a spawned obey but then kick it later.
83 17-Sep-2003 - TJF - Use Dits___Log for logging.
84 22-Sep-2003 - TJF - Add IsDead(), Initial() and Busy() functions and
85 provide initial support for NOTIFY state.
86 16-Dec-2003 - TJF - Add Delete() function.
87 06-Jan-2004 - TJF - DisconHandler destructor must be vitual.
88 26-Jan-2004 - TJF - Add GetDitsPath() method.
89 06-Jul-2004 - TJF - SetName() now looks for a node name and copies
90 it to the right place rather then to the
91 task name part.
92 29-Jul-2013 - TJF DcppTask:: Active(), IsDead(), Initial(), Busy()
93 should all be const but were not. Fixed.
94
95
96 */
97#include "DitsInteraction.h"
98#include "DitsFix.h"
99#include "DitsBulk.h"
100#include "dcpp.h"
101
132DPUBLICCLASS DcppTask {
133
134 public:
145 public:
163 virtual void Disconnected(DcppTask *) = 0;
166 virtual ~DisconHandler() {}
167 };
168
169 private:
170
171 DisconHandler *disconnectHandler;
172
173 /* List element for list of objects of this type */
174 struct TaskListElem {
175 TaskListElem *next;
176 DcppTask *task;
177 };
178 /* Pointer to global list of task objects */
179 static TaskListElem *ObjectList;
180
181 /* Indicates if the disconnect handler has been enabled.*/
182 static bool disconnectEnabled;
183
184 /* Pointer to this task's entry in list */
185 TaskListElem *MyListElem;
186
187 /* Enable the disconnect handler, if not already enabled
188 * Can only be called if DitsAppInit() has been run, hence
189 * not from normally a constructor.
190 */
191 void EnableDisconnect(StatusType *status);
192
193 static bool Log;
194
195
196 static DitsDisConnectRoutineType origDisconnect;
197 static DVOIDP origDisconnectData;
198
199
200 bool taskLog;
201
202 /* The path to the task, if state != INITIAL */
203 DitsPathType path;
204 /* The state of this task object (NOTIFY not yet supported */
205 enum StateEnum { INITIAL, SELFINIT, PATHWAIT1, LOADING,
206 PATHWAIT2, ACTIVE, DIED, NOTIFY } state;
207 /* Buffer sizes */
208 DcppBuffers buffers;
209 /* Flags to the PathGet operation */
210 int pathflags;
211 /* Task priority */
212 int priority;
213 /* Flags to the load command */
214 int loadflags;
215 /* Set true to indicate the last GetPath loaded this task */
216 bool loaded;
217 /* Do we log loads */
218 bool logLoad;
219 /* The name of the task */
220 char taskname[DITS_C_NAMELEN];
221 /* The location of the task */
222 char tasklocation[DcppNodeNameLen];
223 /* The file to load the task from */
224 char taskfile[DcppNodeNameLen];
225 /* The requested process name */
226 char process[DITS_C_NAMELEN];
227 /* Argument to the load command */
228 char argument[DcppArgumentLen];
229 /* Decode string */
230 char decode[DcppNodeNameLen];
231
232 unsigned stackSize;
233
234/*
235 * Various internal routines.
236 */
237 void constructorHelper();
238
239 void Disconnected();
240
241 const char *StateString(StateEnum state) const;
242
243 void LogStartMsg(const char *name, DitsMsgType type,
244 const SdsId & arg, bool forgotten, StatusType *status) const;
245 static void LogArgument(void *client_data, const char *line,
246 StatusType * status);
247 DcppHandlerRet HandlePathWait1(
248 DcppTransaction * const transaction,
249 StatusType * const status);
250 DcppHandlerRet HandleLoading(
251 DcppTransaction * const transaction,
252 StatusType * const status);
253 DcppHandlerRet HandlePathWait2(
254 DcppTransaction * const transaction,
255 StatusType * const status);
256
257 DcppHandlerRet HandleRejected(
258 DcppTransaction * const transaction,
259 StatusType * const status);
260 DcppHandlerRet HandleCompleted(
261 DcppTransaction * const transaction,
262 StatusType * const status);
263 DcppHandlerRet HandleTrigger(
264 DcppTransaction * const transaction,
265 StatusType * const status);
266 DcppHandlerRet HandleErs(
267 DcppTransaction * const transaction,
268 StatusType * const status);
269 DcppHandlerRet HandleMsg(
270 DcppTransaction * const transaction,
271 StatusType * const status);
272 void HandleBulkTrans(
273 DcppTransaction * const transaction,
274 StatusType * const status);
275 DcppHandlerRet HandleBulkDone(
276 DcppTransaction * const transaction,
277 StatusType * const status);
278
279 DcppHandlerRet Send(
280 const char * const name,
281 const DitsMsgType Type,
282 const int flags,
283 const SdsId & arg,
284 const DcppHandlerRoutine SuccessHandler,
285 const DcppHandlerRoutine ErrorHandler,
286 const DcppHandlerRoutine TriggerHandler,
287 const DcppHandlerRoutine ErsHandler,
288 const DcppHandlerRoutine MsgHandler,
289 const DcppVoidPnt ClientData,
290 DitsTransIdType * const transid,
291 StatusType * const status);
292
293 DcppHandlerRet Send(
294 const char * const name,
295 const DitsMsgType Type,
296 const int flags,
297 const DcppShared & SharedMem,
298 const bool sds,
299 const int NotifyBytes,
300 const DcppHandlerRoutine SuccessHandler,
301 const DcppHandlerRoutine ErrorHandler,
302 const DcppHandlerRoutine TriggerHandler,
303 const DcppHandlerRoutine ErsHandler,
304 const DcppHandlerRoutine MsgHandler,
305 const DcppBulkTransRoutine BulkTransHandler,
306 const DcppHandlerRoutine BulkDoneHandler,
307 const DcppVoidPnt ClientData,
308 DitsTransIdType * const transid,
309 StatusType * const status);
310
311 void SendForget(
312 const char * const name,
313 const DitsMsgType Type,
314 const int flags,
315 const SdsId & arg,
316 const DcppHandlerRoutine SuccessHandler,
317 const DcppHandlerRoutine ErrorHandler,
318 const DcppHandlerRoutine TriggerHandler,
319 const DcppHandlerRoutine ErsHandler,
320 const DcppHandlerRoutine MsgHandler,
321 const DcppVoidPnt ClientData,
322 DitsTransIdType * const transid,
323 StatusType * const status);
324
325
326
327
328/*
329 * Prevent Assignment and copying of this type by redefining the
330 * assignment and copy operators to be private.
331 * This ensures we can't get multiple threads controlling the one
332 * task unless done intentionally by the caller.
333 *
334 * Also disallow the default constructor.
335 */
336 DcppTask& operator=(const DcppTask&);
337 DcppTask(const DcppTask&);
338 DcppTask();
339
340
341 public:
356 DcppTask(const char * const name,
357 const char * const location = 0,
358 const char * const file = 0);
359
368 DcppTask(bool self);
369
370
381 DcppTask(DitsPathType p);
382
383
384
387 virtual ~DcppTask();
388/*
389 * Static logging enabling routine. Effects all objects of this type
390 */
396 static void LoggingOn() { Log = true;}
402 static void LoggingOff() { Log = false;}
407 void TaskLoggingOn() { taskLog = true;}
414 void TaskLoggingOff() { taskLog = false;}
420 void Report(StatusType *status) const;
421/*
422 * Inquiries
423 */
428 bool GetPathLoaded() const { return (loaded); };
437 const char * TaskName() const {
438 /* If self path and we have not initilaised yet, have to
439 return the current task's name */
440 if (state == SELFINIT)
441 return DitsGetTaskName();
442 return (taskname);
443 };
453 const char * Location() const { return (tasklocation); };
458 const char * GetArgument() const { return (argument); };
459
460/*
461 * Routines to set various load and get path options.
462 */
476 virtual void SetName(const char * const TaskName) {
477 unsigned i;
478 /*
479 * Copy the task name one character at a time - so that
480 * we can look for a node name.
481 */
482 for (i = 0; (TaskName[i] != 0 && TaskName[i] != '@') ; ++i)
483 {
484 /*
485 * Bail out if too long, ensuring we null terminate the
486 * name (but don't complain - through we probably should)
487 */
488 if (i >= sizeof(taskname)-1)
489 {
490 taskname[sizeof(taskname)-1] = 0;
491 return;
492 }
493 taskname[i] = TaskName[i];
494 }
495 taskname[i] = 0; /* Null terminate the stored name */
496 /*
497 * If we found the node name.
498 */
499 if (TaskName[i] == '@')
500 {
501 unsigned j;
502 ++i; /* Point to first character in node name */
503 /*
504 * Now copy the node name in.
505 */
506 for (j = 0; TaskName[i] != 0 ; ++i, ++j)
507 {
508 if (j >= sizeof(tasklocation)-1)
509 {
510 tasklocation[sizeof(tasklocation)-1] = 0;
511 return;
512 }
513 tasklocation[j] = TaskName[i];
514 }
515 /*
516 * Null terminate.
517 */
518 tasklocation[j] = 0;
519 }
520 };
528 virtual void SetLocation(const char * const Location) {
529 strncpy(tasklocation,Location,sizeof(tasklocation));
530 tasklocation[sizeof(tasklocation)-1] = 0;
531 };
536 virtual void SetFile(const char * const File) {
537 strncpy(taskfile,File,sizeof(taskfile));
538 taskfile[sizeof(taskfile)-1] = 0;
539 };
547 virtual void SetBuffers(const DcppBuffers & Buffers) {
548 this->buffers = Buffers;
549 };
555 virtual void SetFlowControl() {
556 pathflags |= DITS_M_FLOW_CONTROL;
557 }
567 virtual void SetProcess(const char * const ProcessName) {
568 if ((ProcessName) && (strlen(ProcessName) > 0))
569 {
570 strncpy(process,ProcessName,sizeof(process)) ;
571 process[sizeof(process)-1] = 0; /* Null terminate */
572 loadflags |= DITS_M_PROC_NAME;
573 }
574 else
575 loadflags &= ~DITS_M_PROC_NAME;
576 };
577
586 virtual void SetStackSize(unsigned bytes) {
587 stackSize = bytes;
588 if (bytes > 0)
589 loadflags |= DITS_M_SET_BYTES;
590 else
591 loadflags &= ~DITS_M_SET_BYTES;
592 };
593
594
605 virtual void SetArgument(const char * const LoadArg,
606 bool const Append=false)
607 {
608 if (Append)
609 {
610 int len = sizeof(argument) - strlen(argument) - 1;
611 strncat(argument," ",len);
612 --len;
613 strncat(argument,LoadArg,len);
614 }
615 else
616 strncpy(argument,LoadArg,sizeof(argument)) ;
617
618 argument[sizeof(argument)-1] = 0;
619 };
620
632 virtual void SetPriority(const int Priority,
633 const bool Absolute = false) {
634 priority = Priority;
635 if (Absolute)
636 {
637 loadflags &= ~DITS_M_REL_PRIO;
638 loadflags |= DITS_M_ABS_PRIO;
639 }
640 else if (Priority == 0)
641 {
642 loadflags &= ~(DITS_M_REL_PRIO|DITS_M_ABS_PRIO);
643 }
644 else
645 {
646 loadflags &= ~DITS_M_ABS_PRIO;
647 loadflags |= DITS_M_REL_PRIO;
648 }
649 };
650/*
651 IMP_ARG_SPLIT not yet supported
652
653 virtual void SetDecode(const char * const Decode) {
654 if (strlen(Decode) > 0)
655 {
656 strncpy(decode,Decode,sizeof(decode)) ;
657 loadflags |= DITS_M_ARG_SPLIT;
658 }
659 else
660 loadflags &= ~DITS_M_ARG_SPLIT;
661 };
662*/
676 virtual void SetNames(const bool Flag = true) {
677 if (Flag)
678 loadflags |= DITS_M_NAMES;
679 else
680 loadflags &= ~DITS_M_NAMES;
681 };
694 virtual void SetSymbols(const bool Flag = true) {
695 if (Flag)
696 loadflags |= DITS_M_SYMBOL;
697 else
698 loadflags &= ~DITS_M_SYMBOL;
699 };
716 virtual void SetProg(const bool Flag = true) {
717 if (Flag)
718 loadflags |= DITS_M_PROG;
719 else
720 loadflags &= ~DITS_M_PROG;
721 };
729 virtual void LogLoad(const bool Flag = true) {
730 logLoad = Flag;
731 };
732
738 virtual void ClearState() {
739 state = INITIAL;
740 };
747 virtual bool Active() const {
748 return ((state == ACTIVE)||(state == SELFINIT));
749 }
754 virtual bool IsDead() const {
755 return (state == DIED);
756 }
761 virtual bool Initial() const {
762 return ((state == INITIAL)||(state == DIED));
763 }
771 virtual bool Busy() const {
772 return ((state == PATHWAIT1) ||
773 (state == PATHWAIT2) ||
774 (state == LOADING) ||
775 (state == NOTIFY));
776 }
777
811 StatusType * const status,
812 const DcppHandlerRoutine SuccessHandler=0,
813 const DcppHandlerRoutine ErrorHandler=0,
814 const DcppVoidPnt ClientData=0);
815
816
829 virtual void GetPathImmed(StatusType * const status);
830
831
832
835 virtual void Died() {
836 path = 0;
837 state = DIED;
838 }
847 virtual void LosePath(StatusType * const status) {
848 if ((state != INITIAL)&&(state != SELFINIT)&&
849 ( path != 0 )&&(path != DitsGetSelfPath()))
850 DitsLosePath(path,status);
851 Died();
852 }
861 virtual void Delete(int force, StatusType * status) {
862 int known;
863 /* Delete the task, note, we cast away the const as the
864 underlying imp routine is not prototyped correctly */
865 DitsDeleteTask((char *)TaskName(), force, &known, status);
866 Died();
867 }
868/*
869 * Various messages
870 *
871 * Standard Obey function - optionally return transaction id.
872 */
939 virtual DcppHandlerRet Obey(const char * const name,
940 StatusType * const status,
941 const SdsId & arg=SdsNull,
942 const DcppHandlerRoutine SuccessHandler=0,
943 const DcppHandlerRoutine ErrorHandler=0,
944 const DcppHandlerRoutine TriggerHandler=0,
945 const DcppVoidPnt ClientData=0,
946 const DcppHandlerRoutine ErsHandler=0,
947 const DcppHandlerRoutine MsgHandler=0,
948 DitsTransIdType * const transid=0) {
949 return(Send(name,DITS_MSG_OBEY,0,arg,SuccessHandler,
950 ErrorHandler,TriggerHandler,ErsHandler,MsgHandler,
951 ClientData,transid,status));
952 };
953 /*
954 * Version of obey where transaction id Sds id is returned instead of
955 * DitsTransIdType
956 */
957
1028 virtual DcppHandlerRet Obey(const char * const name,
1029 StatusType * const status,
1030 const SdsId & arg,
1031 const DcppHandlerRoutine SuccessHandler,
1032 const DcppHandlerRoutine ErrorHandler,
1033 const DcppHandlerRoutine TriggerHandler,
1034 const DcppVoidPnt ClientData,
1035 const DcppHandlerRoutine ErsHandler,
1036 const DcppHandlerRoutine MsgHandler,
1037 SdsId * const tidArg) {
1038 DitsTransIdType tid = 0;
1039 DcppHandlerRet result = Send(
1040 name,DITS_MSG_OBEY,0,arg,
1041 SuccessHandler,
1042 ErrorHandler,TriggerHandler,ErsHandler,MsgHandler,
1043 ClientData,&tid,status);
1044 DcppSpawnKickArg(tid, tidArg, status);
1045 return result;
1046 };
1047 /* Version where transaction id Sds id is returned instead of
1048 DitsTransIdType. Since the SdsID argument is const, we can
1049 distinish one where we want to update an existing item rather
1050 then create a new item
1051 */
1052
1124 virtual DcppHandlerRet Obey(const char * const name,
1125 StatusType * const status,
1126 const SdsId & arg,
1127 const DcppHandlerRoutine SuccessHandler,
1128 const DcppHandlerRoutine ErrorHandler,
1129 const DcppHandlerRoutine TriggerHandler,
1130 const DcppVoidPnt ClientData,
1131 const DcppHandlerRoutine ErsHandler,
1132 const DcppHandlerRoutine MsgHandler,
1133 const SdsId * const tidArg) {
1134 DitsTransIdType tid = 0;
1135 DcppHandlerRet result = Send(
1136 name,DITS_MSG_OBEY,0,arg,
1137 SuccessHandler,
1138 ErrorHandler,TriggerHandler,ErsHandler,MsgHandler,
1139 ClientData,&tid,status);
1140 DcppSpawnKickArgUpdate(tid, tidArg, status);
1141 return result;
1142 };
1200 virtual DcppHandlerRet Kick(const char * const name,
1201 StatusType * const status,
1202 const SdsId & arg=SdsNull,
1203 const DcppHandlerRoutine SuccessHandler=0,
1204 const DcppHandlerRoutine ErrorHandler=0,
1205 const DcppVoidPnt ClientData=0,
1206 const DcppHandlerRoutine ErsHandler=0,
1207 const DcppHandlerRoutine MsgHandler=0) {
1208 return(Send(name,DITS_MSG_KICK,0,arg,SuccessHandler,
1209 ErrorHandler,0,ErsHandler,MsgHandler,
1210 ClientData,0,status));
1211 };
1212 /* Bulk data versions of the above */
1295 virtual DcppHandlerRet Obey(const char * const name,
1296 const DcppShared & SharedMem,
1297 const bool sds,
1298 const int NotifyBytes,
1299 StatusType * const status,
1300 const DcppHandlerRoutine SuccessHandler=0,
1301 const DcppHandlerRoutine ErrorHandler=0,
1302 const DcppBulkTransRoutine BulkTransHandler=0,
1303 const DcppHandlerRoutine BulkDoneHandler=0,
1304 const DcppHandlerRoutine TriggerHandler=0,
1305 const DcppVoidPnt ClientData=0,
1306 const DcppHandlerRoutine ErsHandler=0,
1307 const DcppHandlerRoutine MsgHandler=0,
1308 DitsTransIdType * const transid=0) {
1309 return(Send(name,DITS_MSG_OBEY,0,
1310 SharedMem,sds,NotifyBytes,
1311 SuccessHandler, ErrorHandler,TriggerHandler,
1312 ErsHandler,MsgHandler,
1313 BulkTransHandler, BulkDoneHandler,
1314 ClientData,transid,status));
1315 };
1402 virtual DcppHandlerRet Obey(const char * const name,
1403 const DcppShared & SharedMem,
1404 const bool sds,
1405 const int NotifyBytes,
1406 StatusType * const status,
1407 const DcppHandlerRoutine SuccessHandler,
1408 const DcppHandlerRoutine ErrorHandler,
1409 const DcppBulkTransRoutine BulkTransHandler,
1410 const DcppHandlerRoutine BulkDoneHandler,
1411 const DcppHandlerRoutine TriggerHandler,
1412 const DcppVoidPnt ClientData,
1413 const DcppHandlerRoutine ErsHandler,
1414 const DcppHandlerRoutine MsgHandler,
1415 SdsId * const tidArg) {
1416
1417 DitsTransIdType tid = 0;
1418 DcppHandlerRet result = Send(
1419 name,DITS_MSG_OBEY,0,
1420 SharedMem,sds,NotifyBytes,
1421 SuccessHandler, ErrorHandler,TriggerHandler,
1422 ErsHandler,MsgHandler,
1423 BulkTransHandler, BulkDoneHandler,
1424 ClientData,&tid,status);
1425 DcppSpawnKickArg(tid, tidArg, status);
1426 return result;
1427
1428 };
1516 virtual DcppHandlerRet Obey(const char * const name,
1517 const DcppShared & SharedMem,
1518 const bool sds,
1519 const int NotifyBytes,
1520 StatusType * const status,
1521 const DcppHandlerRoutine SuccessHandler,
1522 const DcppHandlerRoutine ErrorHandler,
1523 const DcppBulkTransRoutine BulkTransHandler,
1524 const DcppHandlerRoutine BulkDoneHandler,
1525 const DcppHandlerRoutine TriggerHandler,
1526 const DcppVoidPnt ClientData,
1527 const DcppHandlerRoutine ErsHandler,
1528 const DcppHandlerRoutine MsgHandler,
1529 const SdsId * const tidArg) {
1530
1531 DitsTransIdType tid = 0;
1532 DcppHandlerRet result = Send(
1533 name,DITS_MSG_OBEY,0,
1534 SharedMem,sds,NotifyBytes,
1535 SuccessHandler, ErrorHandler,TriggerHandler,
1536 ErsHandler,MsgHandler,
1537 BulkTransHandler, BulkDoneHandler,
1538 ClientData,&tid,status);
1539 DcppSpawnKickArgUpdate(tid, tidArg, status);
1540 return result;
1541
1542 };
1616 virtual DcppHandlerRet Kick(const char * const name,
1617 const DcppShared & SharedMem,
1618 const bool sds,
1619 const int NotifyBytes,
1620 StatusType * const status,
1621 const DcppHandlerRoutine SuccessHandler=0,
1622 const DcppHandlerRoutine ErrorHandler=0,
1623 const DcppBulkTransRoutine BulkTransHandler=0,
1624 const DcppHandlerRoutine BulkDoneHandler=0,
1625 const DcppVoidPnt ClientData=0,
1626 const DcppHandlerRoutine ErsHandler=0,
1627 const DcppHandlerRoutine MsgHandler=0) {
1628 return(Send(name,DITS_MSG_KICK,0,
1629 SharedMem,sds,NotifyBytes,
1630 SuccessHandler, ErrorHandler,0,
1631 ErsHandler,MsgHandler,
1632 BulkTransHandler, BulkDoneHandler,
1633 ClientData,0,status));
1634 };
1685 virtual DcppHandlerRet Get(const char * const name,
1686 StatusType * const status,
1687 const DcppHandlerRoutine SuccessHandler=0,
1688 const DcppHandlerRoutine ErrorHandler=0,
1689 const DcppVoidPnt ClientData=0,
1690 const DcppHandlerRoutine ErsHandler=0) {
1691 return(Send(name,DITS_MSG_GETPARAM,0,SdsNull,SuccessHandler,
1692 ErrorHandler,0,ErsHandler,0,
1693 ClientData,0,status));
1694 };
1738 const DcppHandlerRoutine SuccessHandler,
1739 const DcppHandlerRoutine ErrorHandler,
1740 const DcppVoidPnt ClientData, unsigned count,
1741 StatusType * status, ...);
1742
1794 const DcppHandlerRoutine SuccessHandler,
1795 const DcppHandlerRoutine ErrorHandler,
1796 const DcppHandlerRoutine ErsHandler,
1797 const DcppVoidPnt ClientData, unsigned count,
1798 StatusType * status, ...);
1799
1848 virtual DcppHandlerRet Set(const char * const name,
1849 StatusType * const status,
1850 const SdsId & arg = SdsNull,
1851 const DcppHandlerRoutine SuccessHandler=0,
1852 const DcppHandlerRoutine ErrorHandler=0,
1853 const DcppVoidPnt ClientData=0,
1854 const DcppHandlerRoutine ErsHandler=0) {
1855 return(Send(name,DITS_MSG_SETPARAM,0,arg,SuccessHandler,
1856 ErrorHandler,0,ErsHandler,0,
1857 ClientData,0,status));
1858 };
1913 virtual DcppHandlerRet Control(const char * const name,
1914 StatusType * const status,
1915 const SdsId & arg=SdsNull,
1916 const DcppHandlerRoutine SuccessHandler=0,
1917 const DcppHandlerRoutine ErrorHandler=0,
1918 const DcppHandlerRoutine TriggerHandler=0,
1919 const DcppVoidPnt ClientData=0,
1920 const DcppHandlerRoutine ErsHandler=0) {
1921 return(Send(name,DITS_MSG_CONTROL,0,arg,SuccessHandler,
1922 ErrorHandler,TriggerHandler,ErsHandler,0,
1923 ClientData,0,status));
1924 };
1987 virtual DcppHandlerRet Monitor(const char *name,
1988 StatusType * const status,
1989 const SdsId & arg=SdsNull,
1990 const DcppHandlerRoutine SuccessHandler=0,
1991 const DcppHandlerRoutine ErrorHandler=0,
1992 const DcppHandlerRoutine TriggerHandler=0,
1993 const DcppVoidPnt ClientData=0,
1994 const bool SendCurrent=false,
1995 const DcppHandlerRoutine ErsHandler=0) {
1996 int flags = SendCurrent ? DITS_M_SENDCUR : 0;
1997 return(Send(name,DITS_MSG_MONITOR,flags,arg,SuccessHandler,
1998 ErrorHandler,TriggerHandler,ErsHandler,0,
1999 ClientData,0,status));
2000 };
2001 /*
2002 * Forget Versions - Obey and Monitor only
2003 */
2070 virtual void ObeyForget(const char * const name,
2071 StatusType * const status,
2072 const SdsId & arg=SdsNull,
2073 const DcppHandlerRoutine SuccessHandler=0,
2074 const DcppHandlerRoutine ErrorHandler=0,
2075 const DcppHandlerRoutine TriggerHandler=0,
2076 const DcppVoidPnt ClientData=0,
2077 const DcppHandlerRoutine ErsHandler=0,
2078 const DcppHandlerRoutine MsgHandler=0,
2079 DitsTransIdType * const transid=0) {
2080 SendForget(name,DITS_MSG_OBEY,0,arg,SuccessHandler,
2081 ErrorHandler,TriggerHandler,ErsHandler,MsgHandler,
2082 ClientData,transid,status);
2083 };
2153 virtual void ObeyForget(const char * const name,
2154 StatusType * const status,
2155 const SdsId & arg,
2156 const DcppHandlerRoutine SuccessHandler,
2157 const DcppHandlerRoutine ErrorHandler,
2158 const DcppHandlerRoutine TriggerHandler,
2159 const DcppVoidPnt ClientData,
2160 const DcppHandlerRoutine ErsHandler,
2161 const DcppHandlerRoutine MsgHandler,
2162 SdsId * const tidArg) {
2163 DitsTransIdType tid = 0;
2164 SendForget(name,DITS_MSG_OBEY,0,arg,SuccessHandler,
2165 ErrorHandler,TriggerHandler,ErsHandler,MsgHandler,
2166 ClientData,&tid,status);
2167 DcppSpawnKickArg(tid, tidArg, status);
2168 };
2239 virtual void ObeyForget(const char * const name,
2240 StatusType * const status,
2241 const SdsId & arg,
2242 const DcppHandlerRoutine SuccessHandler,
2243 const DcppHandlerRoutine ErrorHandler,
2244 const DcppHandlerRoutine TriggerHandler,
2245 const DcppVoidPnt ClientData,
2246 const DcppHandlerRoutine ErsHandler,
2247 const DcppHandlerRoutine MsgHandler,
2248 const SdsId * const tidArg) {
2249 DitsTransIdType tid = 0;
2250 SendForget(name,DITS_MSG_OBEY,0,arg,SuccessHandler,
2251 ErrorHandler,TriggerHandler,ErsHandler,MsgHandler,
2252 ClientData,&tid,status);
2253 DcppSpawnKickArgUpdate(tid, tidArg, status);
2254 };
2311 virtual void KickForget(const char * const name,
2312 StatusType * const status,
2313 const SdsId & arg=SdsNull,
2314 const DcppHandlerRoutine SuccessHandler=0,
2315 const DcppHandlerRoutine ErrorHandler=0,
2316 const DcppVoidPnt ClientData=0,
2317 const DcppHandlerRoutine ErsHandler=0,
2318 const DcppHandlerRoutine MsgHandler=0) {
2319 SendForget(name,DITS_MSG_KICK,0,arg,SuccessHandler,
2320 ErrorHandler,0,ErsHandler,MsgHandler,
2321 ClientData,0,status);
2322 };
2381 virtual void MonitorForget(const char *name,
2382 StatusType * const status,
2383 const SdsId & arg=SdsNull,
2384 const DcppHandlerRoutine SuccessHandler=0,
2385 const DcppHandlerRoutine ErrorHandler=0,
2386 const DcppHandlerRoutine TriggerHandler=0,
2387 const DcppVoidPnt ClientData=0,
2388 const bool SendCurrent=false,
2389 const DcppHandlerRoutine ErsHandler=0) {
2390 int flags = SendCurrent ? DITS_M_SENDCUR : 0;
2391 SendForget(name,DITS_MSG_MONITOR,flags,arg,SuccessHandler,
2392 ErrorHandler,TriggerHandler,ErsHandler,0,
2393 ClientData,0,status);
2394 };
2395
2408 DisconHandler *old = disconnectHandler;
2409 disconnectHandler = p;
2410 return old;
2411 }
2412
2420 StatusType * status);
2421
2434 StatusType * status) ;
2435
2445 virtual void GetDitsPath(DitsPathType *path, StatusType *status);
2446
2451 static DVOID HandleDisconnected(const char *task,
2452 DitsPathType path,
2453 StatusType *status);
2454};
2455
2456
2457#endif
A structure representing message buffer sizes.
Definition dcpp.h:287
This is used to create and represent a shared memory segment.
Definition dcpp.h:499
DisconHandler()
Constructor.
Definition dcpptask.h:148
virtual void Disconnected(DcppTask *)=0
Disconnect notification routine.
virtual ~DisconHandler()
Destructor.
Definition dcpptask.h:166
Disconnect handler abstract type.
Definition dcpptask.h:144
virtual void SetBuffers(const DcppBuffers &Buffers)
Set the DRAMA path buffers.
Definition dcpptask.h:547
virtual DcppHandlerRet Kick(const char *const name, const DcppShared &SharedMem, const bool sds, const int NotifyBytes, StatusType *const status, const DcppHandlerRoutine SuccessHandler=0, const DcppHandlerRoutine ErrorHandler=0, const DcppBulkTransRoutine BulkTransHandler=0, const DcppHandlerRoutine BulkDoneHandler=0, const DcppVoidPnt ClientData=0, const DcppHandlerRoutine ErsHandler=0, const DcppHandlerRoutine MsgHandler=0)
Send a DRAMA bulk data Kick message to the task.
Definition dcpptask.h:1616
static void LoggingOff()
Disable logging for all tasks.
Definition dcpptask.h:402
void Report(StatusType *status) const
Dump details using <a href="../routines/MsgOut.html">MsgOut()</a>.
virtual void SetSymbols(const bool Flag=true)
Interpert file name as a symbol (VMS Target only)
Definition dcpptask.h:694
static DcppHandlerRet DiscardResponse(DcppVoidPnt ClientData, StatusType *status)
Flag argument success handler indicating reponses are to be ignored.
virtual void SetNames(const bool Flag=true)
Insist that symbols known to IMP_Master be known to the task.
Definition dcpptask.h:676
virtual DcppHandlerRet MGet(const DcppHandlerRoutine SuccessHandler, const DcppHandlerRoutine ErrorHandler, const DcppVoidPnt ClientData, unsigned count, StatusType *status,...)
Send a DRAMA message to the task to get the value of multiple parameters.
DcppTask(bool self)
Path to self constructor.
virtual void LosePath(StatusType *const status)
Lose the path and then set as if the task has died.
Definition dcpptask.h:847
virtual void ObeyForget(const char *const name, StatusType *const status, const SdsId &arg, const DcppHandlerRoutine SuccessHandler, const DcppHandlerRoutine ErrorHandler, const DcppHandlerRoutine TriggerHandler, const DcppVoidPnt ClientData, const DcppHandlerRoutine ErsHandler, const DcppHandlerRoutine MsgHandler, const SdsId *const tidArg)
Send a DRAMA Obey message to the task, forgetting the transaction.
Definition dcpptask.h:2239
virtual DcppHandlerRet GetPath(StatusType *const status, const DcppHandlerRoutine SuccessHandler=0, const DcppHandlerRoutine ErrorHandler=0, const DcppVoidPnt ClientData=0)
Get a path to/load a the task.
virtual ~DcppTask()
Destructor.
virtual void SetLocation(const char *const Location)
Set the task location.
Definition dcpptask.h:528
static void HandleDisconnected(const char *task, DitsPathType path, StatusType *status)
Handle task disconnection.
virtual DcppHandlerRet Obey(const char *const name, StatusType *const status, const SdsId &arg=SdsNull, const DcppHandlerRoutine SuccessHandler=0, const DcppHandlerRoutine ErrorHandler=0, const DcppHandlerRoutine TriggerHandler=0, const DcppVoidPnt ClientData=0, const DcppHandlerRoutine ErsHandler=0, const DcppHandlerRoutine MsgHandler=0, DitsTransIdType *const transid=0)
Send a DRAMA Obey message to the task.
Definition dcpptask.h:939
virtual void Died()
Note that a task has died.
Definition dcpptask.h:835
virtual void KickForget(const char *const name, StatusType *const status, const SdsId &arg=SdsNull, const DcppHandlerRoutine SuccessHandler=0, const DcppHandlerRoutine ErrorHandler=0, const DcppVoidPnt ClientData=0, const DcppHandlerRoutine ErsHandler=0, const DcppHandlerRoutine MsgHandler=0)
Send a DRAMA OKick message to the task, forgetting the transaction.
Definition dcpptask.h:2311
virtual void SetArgument(const char *const LoadArg, bool const Append=false)
Set the load time argument string.
Definition dcpptask.h:605
DcppTask(DitsPathType p)
Constructor from existing path.
virtual DcppHandlerRet Obey(const char *const name, StatusType *const status, const SdsId &arg, const DcppHandlerRoutine SuccessHandler, const DcppHandlerRoutine ErrorHandler, const DcppHandlerRoutine TriggerHandler, const DcppVoidPnt ClientData, const DcppHandlerRoutine ErsHandler, const DcppHandlerRoutine MsgHandler, SdsId *const tidArg)
Send a DRAMA Obey message to the task.
Definition dcpptask.h:1028
virtual DisconHandler * PutDisconnectHandler(DisconHandler *p)
Add a new disconnect handler for this task.
Definition dcpptask.h:2407
void TaskLoggingOff()
Turn logging off for this object.
Definition dcpptask.h:414
virtual void MonitorForget(const char *name, StatusType *const status, const SdsId &arg=SdsNull, const DcppHandlerRoutine SuccessHandler=0, const DcppHandlerRoutine ErrorHandler=0, const DcppHandlerRoutine TriggerHandler=0, const DcppVoidPnt ClientData=0, const bool SendCurrent=false, const DcppHandlerRoutine ErsHandler=0)
Send a DRAMA Monitor message to the task, forgetting the transaction.
Definition dcpptask.h:2381
virtual void SetPriority(const int Priority, const bool Absolute=false)
Set the load time priority for a task when loaded.
Definition dcpptask.h:632
virtual DcppHandlerRet Obey(const char *const name, const DcppShared &SharedMem, const bool sds, const int NotifyBytes, StatusType *const status, const DcppHandlerRoutine SuccessHandler, const DcppHandlerRoutine ErrorHandler, const DcppBulkTransRoutine BulkTransHandler, const DcppHandlerRoutine BulkDoneHandler, const DcppHandlerRoutine TriggerHandler, const DcppVoidPnt ClientData, const DcppHandlerRoutine ErsHandler, const DcppHandlerRoutine MsgHandler, const SdsId *const tidArg)
Send a DRAMA Obey bulk data message to the task.
Definition dcpptask.h:1516
DcppHandlerRet HandleMessage(DcppTransaction *transaction, StatusType *status)
Function used by DcppDispatch in dispatching to handlers.
virtual DcppHandlerRet Obey(const char *const name, const DcppShared &SharedMem, const bool sds, const int NotifyBytes, StatusType *const status, const DcppHandlerRoutine SuccessHandler=0, const DcppHandlerRoutine ErrorHandler=0, const DcppBulkTransRoutine BulkTransHandler=0, const DcppHandlerRoutine BulkDoneHandler=0, const DcppHandlerRoutine TriggerHandler=0, const DcppVoidPnt ClientData=0, const DcppHandlerRoutine ErsHandler=0, const DcppHandlerRoutine MsgHandler=0, DitsTransIdType *const transid=0)
Send a DRAMA Obey bulk data message to the task.
Definition dcpptask.h:1295
static void LoggingOn()
Enable logging for all DcppTask objects.
Definition dcpptask.h:396
virtual void SetStackSize(unsigned bytes)
Set the stack size for the load.
Definition dcpptask.h:586
virtual DcppHandlerRet Get(const char *const name, StatusType *const status, const DcppHandlerRoutine SuccessHandler=0, const DcppHandlerRoutine ErrorHandler=0, const DcppVoidPnt ClientData=0, const DcppHandlerRoutine ErsHandler=0)
Send a DRAMA message to the task to get the value of a parameter.
Definition dcpptask.h:1685
virtual DcppHandlerRet Control(const char *const name, StatusType *const status, const SdsId &arg=SdsNull, const DcppHandlerRoutine SuccessHandler=0, const DcppHandlerRoutine ErrorHandler=0, const DcppHandlerRoutine TriggerHandler=0, const DcppVoidPnt ClientData=0, const DcppHandlerRoutine ErsHandler=0)
Send a DRAMA Control message to the task.
Definition dcpptask.h:1913
DcppTask(const char *const name, const char *const location=0, const char *const file=0)
Normal constructor.
virtual void SetProcess(const char *const ProcessName)
Set the process names.
Definition dcpptask.h:567
virtual void GetDitsPath(DitsPathType *path, StatusType *status)
Return the underlying DITS path object.
virtual DcppHandlerRet Set(const char *const name, StatusType *const status, const SdsId &arg=SdsNull, const DcppHandlerRoutine SuccessHandler=0, const DcppHandlerRoutine ErrorHandler=0, const DcppVoidPnt ClientData=0, const DcppHandlerRoutine ErsHandler=0)
Send a DRAMA set message to the task.
Definition dcpptask.h:1848
virtual DcppHandlerRet Obey(const char *const name, const DcppShared &SharedMem, const bool sds, const int NotifyBytes, StatusType *const status, const DcppHandlerRoutine SuccessHandler, const DcppHandlerRoutine ErrorHandler, const DcppBulkTransRoutine BulkTransHandler, const DcppHandlerRoutine BulkDoneHandler, const DcppHandlerRoutine TriggerHandler, const DcppVoidPnt ClientData, const DcppHandlerRoutine ErsHandler, const DcppHandlerRoutine MsgHandler, SdsId *const tidArg)
Send a DRAMA Obey bulk data message to the task.
Definition dcpptask.h:1402
virtual bool Initial() const
Return true if a GetPath operation is required.
Definition dcpptask.h:761
bool GetPathLoaded() const
Indicate if a the task was loaded.
Definition dcpptask.h:428
virtual DcppHandlerRet Monitor(const char *name, StatusType *const status, const SdsId &arg=SdsNull, const DcppHandlerRoutine SuccessHandler=0, const DcppHandlerRoutine ErrorHandler=0, const DcppHandlerRoutine TriggerHandler=0, const DcppVoidPnt ClientData=0, const bool SendCurrent=false, const DcppHandlerRoutine ErsHandler=0)
Send a DRAMA Monitor message to the task.
Definition dcpptask.h:1987
virtual void ObeyForget(const char *const name, StatusType *const status, const SdsId &arg=SdsNull, const DcppHandlerRoutine SuccessHandler=0, const DcppHandlerRoutine ErrorHandler=0, const DcppHandlerRoutine TriggerHandler=0, const DcppVoidPnt ClientData=0, const DcppHandlerRoutine ErsHandler=0, const DcppHandlerRoutine MsgHandler=0, DitsTransIdType *const transid=0)
Send a DRAMA Obey message to the task, forgetting the transaction.
Definition dcpptask.h:2070
virtual bool Busy() const
Returns true if we can't send a message because path is busy.
Definition dcpptask.h:771
virtual void SetFlowControl()
Set the FLOW control flag.
Definition dcpptask.h:555
virtual bool Active() const
Indicate if a task is active.
Definition dcpptask.h:747
virtual void GetPathImmed(StatusType *const status)
Get a path to a task if DITS already has it.
virtual bool IsDead() const
Return true if a previously active task has disconnected.
Definition dcpptask.h:754
virtual void ObeyForget(const char *const name, StatusType *const status, const SdsId &arg, const DcppHandlerRoutine SuccessHandler, const DcppHandlerRoutine ErrorHandler, const DcppHandlerRoutine TriggerHandler, const DcppVoidPnt ClientData, const DcppHandlerRoutine ErsHandler, const DcppHandlerRoutine MsgHandler, SdsId *const tidArg)
Send a DRAMA Obey message to the task, forgetting the transaction.
Definition dcpptask.h:2153
const char * TaskName() const
Fetch the task name.
Definition dcpptask.h:437
virtual DcppHandlerRet Obey(const char *const name, StatusType *const status, const SdsId &arg, const DcppHandlerRoutine SuccessHandler, const DcppHandlerRoutine ErrorHandler, const DcppHandlerRoutine TriggerHandler, const DcppVoidPnt ClientData, const DcppHandlerRoutine ErsHandler, const DcppHandlerRoutine MsgHandler, const SdsId *const tidArg)
Send a DRAMA Obey message to the task.
Definition dcpptask.h:1124
virtual void SetFile(const char *const File)
Set the executable file name.
Definition dcpptask.h:536
virtual DcppHandlerRet Kick(const char *const name, StatusType *const status, const SdsId &arg=SdsNull, const DcppHandlerRoutine SuccessHandler=0, const DcppHandlerRoutine ErrorHandler=0, const DcppVoidPnt ClientData=0, const DcppHandlerRoutine ErsHandler=0, const DcppHandlerRoutine MsgHandler=0)
Send a DRAMA Kick message to the task.
Definition dcpptask.h:1200
const char * Location() const
Fetch the task location.
Definition dcpptask.h:453
const char * GetArgument() const
Fetch the load argument.
Definition dcpptask.h:458
virtual DcppHandlerRet MGet(const DcppHandlerRoutine SuccessHandler, const DcppHandlerRoutine ErrorHandler, const DcppHandlerRoutine ErsHandler, const DcppVoidPnt ClientData, unsigned count, StatusType *status,...)
Send a DRAMA message to the task to get the value of multiple parameters.
virtual void LogLoad(const bool Flag=true)
Load use <a href="../routines/MsgOut.html">MsgOut()</a> a lines indicating the load operations.
Definition dcpptask.h:729
void TaskLoggingOn()
Turn logging on for this object.
Definition dcpptask.h:407
virtual void SetName(const char *const TaskName)
Set the task name.
Definition dcpptask.h:476
virtual void Delete(int force, StatusType *status)
Delete the task.
Definition dcpptask.h:861
virtual void SetProg(const bool Flag=true)
Interpert file name as a program name.
Definition dcpptask.h:716
virtual void ClearState()
Clear the task state.
Definition dcpptask.h:738
A Class which provides access to DRAMA's message sending facilities.
Definition dcpptask.h:132
A type used to connect DcppHandler and DcppTask.
Definition dcpp.h:352
A C++ Interface to the handling SDS structures.
Definition sds.h:761
void DcppSpawnKickArgUpdate(DitsTransIdType transid, const SdsId *id, StatusType *status)
Update an argument structure used when kick actions which spawn.
void * DcppVoidPnt
A pointer to void
Definition dcpp.h:59
void(* DcppBulkTransRoutine)(unsigned long Transferred, unsigned long Total, DcppVoidPnt ClientData, StatusType *status)
Type for call backs for DITS_REA_TRANSFERRED messages.
Definition dcpp.h:106
DcppHandlerRet(* DcppHandlerRoutine)(DcppVoidPnt ClientData, StatusType *status)
Type for call backs when messages arrive.
Definition dcpp.h:92
DcppHandlerRet
Type returns by various routines to indicate what is to happen next.
Definition dcpp.h:75
void DcppSpawnKickArg(DitsTransIdType transid, SdsId *id, StatusType *status)
Create an argument structure used when kick actions which spawn.
const unsigned DcppNodeNameLen
Maximum Node name length
Definition dcpp.h:57
const unsigned DcppArgumentLen
Maximum Node name length
Definition dcpp.h:58