AAO DRAMA C++ Interface (Old style)
DRAMA C++, Depreciated, don't use for new code
dcppmonitor.h
Go to the documentation of this file.
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 dcppmonitor_h
29#define dcppmonitor_h
30/* d c p p m o n i t o r
31
32 * Module name:
33 dcppmonitor.h
34
35 * Function:
36 A class that which used DcppTask to support parameter monitoring.
37
38 * Description:
39 This class provides a wrap around to parameter monitoring operations.
40 It uses a DcppTask object previously constructed by the user and
41 on which a GetPath operation must have been completed.
42
43 This file now uses DOXYGEN comments to generate the C++ web pages.
44 m4 macros of the form @htmlonly <a href="../routines/function.html">function()</a>@endhtmlonly are used in the comments
45 to refer to DRAMA C function documentation (see DramaHtml/Makefile,
46 DramaHtml/doxygen.config and DramaHtml/filter.m4 for detials)
47
48 * Language:
49 C++
50
51 * Support: Tony Farrell, AAO
52
53 * Copyright (c) Anglo-Australian Telescope Board, 1995.
54 Not to be used for commercial purposes without AATB permission.
55
56 * @(#) $Id$
57
58 * History:
59 12-Oct-1995 - TJF - Original version. Extracted from dcpp.h.
60 10-Sep-1997 - TJF - Add IsInitial(), IsStarting() and IsActive().
61 09-Dec-1997 - TJF - Declare class with DPUBLICCLASS to allow
62 export from WIN32 DLL.
63 16-Mar-2006 - TJF - monId should be INT32 - to avoid compiler warnings
64 with the new SDS Arg calls.
65
66 */
67#include "dcpptask.h"
68/*
69 * This file now uses DOXYGEN comments - the following is placed into the
70 * index page. note that the @file block says to include the typedefs,
71 * functions etc from this file into the documentation.
72 */
73
82typedef void (*DcppMonChangedRoutine)
83 (const char *name, SdsCodeType type, DcppVoidPnt value,
84 DcppVoidPnt ClientData, StatusType * status);
85
105DPUBLICCLASS DcppMonitor {
106 private:
107 DcppTask *task;
108 DcppMonChangedRoutine changedHandler;
109 DcppHandlerRoutine completedHandler;
110 DcppHandlerRoutine startHandler;
111 DcppVoidPnt clientData;
112 enum StateEnum { INIT, WAIT_ID, ACTIVE } state;
113 INT32 monId;
114
115
116 const char *StateString(StateEnum state) const;
117 static DcppHandlerRet CompHandler(DcppVoidPnt ClientData,
118 StatusType * status);
119 static DcppHandlerRet StartedHandler(DcppVoidPnt ClientData,
120 StatusType *status);
121 static DcppHandlerRet TrigHandler(DcppVoidPnt ClientData,
122 StatusType * status);
123
124
125 /* kept for link time compatiblity only - should not be invoked
126 any more. Use DcppVarArgsToSds() for all code.
127 */
128 void FormatArg(int count,
129 Arg& ArgId,
130 StatusType * status,
131 va_list args);
132
133
134
135/*
136 * Prevent Assignment and copying of this type by redefining the
137 * assignment and copy operators to be private.
138 * This ensures we can't get multiple threads controlling the one
139 * task unless done intentionally by the caller.
140 *
141 * Also disallow the default constructor.
142 */
143 DcppMonitor& operator=(const DcppMonitor&);
144 DcppMonitor(const DcppMonitor&);
145 DcppMonitor();
146
147
148
149
150 public:
155 DcppMonitor(DcppTask * Task) { task = Task; state = INIT; };
156
161 DcppTask * Task() const { return task; };
162
191 const DcppMonChangedRoutine ChangedHandler,
192 const DcppHandlerRoutine CompletedHandler,
193 const DcppVoidPnt ClientData,
194 const bool SendCurrent,
195 const int count, StatusType * const status, ...);
224 const DcppMonChangedRoutine ChangedHandler,
225 const DcppHandlerRoutine CompletedHandler,
226 const DcppVoidPnt ClientData,
227 const bool SendCurrent,
228 const int count, StatusType * const status, ...);
258 const char * const MTask,
259 const char * const Action,
260 const DcppHandlerRoutine CompletedHandler,
261 const DcppVoidPnt ClientData,
262 const bool SendCurrent,
263 const int count, StatusType * const status, ...);
295 const char * const MTask,
296 const char * const Action,
297 const DcppHandlerRoutine StartedHandler,
298 const DcppHandlerRoutine CompletedHandler,
299 const DcppVoidPnt ClientData,
300 const bool SendCurrent,
301 const int count, StatusType * const status, ...);
330 const char * const MTask,
331 const char * const Action,
332 const DcppHandlerRoutine CompletedHandler,
333 const DcppVoidPnt ClientData,
334 const bool SendCurrent,
335 const int count, StatusType * const status, ...);
367 const char * const MTask,
368 const char * const Action,
369 const DcppHandlerRoutine StartHandler,
370 const DcppHandlerRoutine CompletedHandler,
371 const DcppVoidPnt ClientData,
372 const bool SendCurrent,
373 const int count, StatusType * const status, ...);
374
405 void Add (
406 const char * const name,
407 StatusType * const status,
408 const DcppHandlerRoutine SuccessHandler = 0,
409 const DcppHandlerRoutine ErrorHandler = 0,
410 const DcppVoidPnt ClientData = 0) const ;
441 void Delete (
442 const char * const name,
443 StatusType * const status,
444 const DcppHandlerRoutine SuccessHandler = 0,
445 const DcppHandlerRoutine ErrorHandler = 0,
446 const DcppVoidPnt ClientData = 0) const ;
447
477 void Cancel (
478 StatusType * const status,
479 const DcppHandlerRoutine SuccessHandler = 0,
480 const DcppHandlerRoutine ErrorHandler = 0,
481 const DcppVoidPnt ClientData = 0) const ;
482
487 bool IsInitial() {
488 return (state == INIT);
489 }
495 bool IsStarting() {
496 return (state == WAIT_ID);
497 }
502 bool IsActive() {
503 return (state == ACTIVE);
504 }
508 void Reset() {
509 state = INIT;
510 }
511};
512
513#endif
A C++ Interface to the SDS Arg library.
Definition arg.h:263
void ForwardForget(const char *const MTask, const char *const Action, const DcppHandlerRoutine CompletedHandler, const DcppVoidPnt ClientData, const bool SendCurrent, const int count, StatusType *const status,...)
Start a monitor forward operation but orphan it.
bool IsInitial()
Returns true if the monitor operation has not yet been started.
Definition dcppmonitor.h:487
void Forward(const char *const MTask, const char *const Action, const DcppHandlerRoutine StartedHandler, const DcppHandlerRoutine CompletedHandler, const DcppVoidPnt ClientData, const bool SendCurrent, const int count, StatusType *const status,...)
Start a monitor forward operation, with started handler.
void Delete(const char *const name, StatusType *const status, const DcppHandlerRoutine SuccessHandler=0, const DcppHandlerRoutine ErrorHandler=0, const DcppVoidPnt ClientData=0) const
Delete a parameter from the list of parameters being monitored.
void Reset()
Reset the state of the monitor.
Definition dcppmonitor.h:508
DcppTask * Task() const
Return the associated task object.
Definition dcppmonitor.h:161
bool IsActive()
Returns true if the monitor operation is active.
Definition dcppmonitor.h:502
void Cancel(StatusType *const status, const DcppHandlerRoutine SuccessHandler=0, const DcppHandlerRoutine ErrorHandler=0, const DcppVoidPnt ClientData=0) const
Trigger the cancelling of a monitor operation.
void ForwardStartForget(const char *const MTask, const char *const Action, const DcppHandlerRoutine StartHandler, const DcppHandlerRoutine CompletedHandler, const DcppVoidPnt ClientData, const bool SendCurrent, const int count, StatusType *const status,...)
Start a monitor forward operation but orphan it after starting.
void Monitor(const DcppMonChangedRoutine ChangedHandler, const DcppHandlerRoutine CompletedHandler, const DcppVoidPnt ClientData, const bool SendCurrent, const int count, StatusType *const status,...)
Start a monitor operation.
bool IsStarting()
Returns true if the monitor operation is currently starting.
Definition dcppmonitor.h:495
void Add(const char *const name, StatusType *const status, const DcppHandlerRoutine SuccessHandler=0, const DcppHandlerRoutine ErrorHandler=0, const DcppVoidPnt ClientData=0) const
Add a parameter to the list of parameters being monitored.
void Forward(const char *const MTask, const char *const Action, const DcppHandlerRoutine CompletedHandler, const DcppVoidPnt ClientData, const bool SendCurrent, const int count, StatusType *const status,...)
Start a monitor forward operation.
DcppMonitor(DcppTask *Task)
Construct a parameter monitor controller for the specified task.
Definition dcppmonitor.h:155
void MonitorForget(const DcppMonChangedRoutine ChangedHandler, const DcppHandlerRoutine CompletedHandler, const DcppVoidPnt ClientData, const bool SendCurrent, const int count, StatusType *const status,...)
Start a monitor operation but orphan it.
A class which runs DRAMA parameter monitoring transactions.
Definition dcppmonitor.h:105
A Class which provides access to DRAMA's message sending facilities.
Definition dcpptask.h:132
void * DcppVoidPnt
A pointer to void
Definition dcpp.h:59
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(* DcppMonChangedRoutine)(const char *name, SdsCodeType type, DcppVoidPnt value, DcppVoidPnt ClientData, StatusType *status)
Type for monitor changed callbacks.
Definition dcppmonitor.h:83