AAO DRAMA C++ Interface (Old style)
DRAMA C++, Depreciated, don't use for new code
Git.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 GITINC
29#define GITINC
30/*
31 * Copyright (c) Anglo-Australian Telescope Board, 1995.
32 * Not to be used for commercial purposes without AATB permission.
33 *
34 * @(#) $Id$
35 *
36 * This file now uses DOXYGEN comments to generate the C++ web pages.
37 * m4 macros of the form @htmlonly <a href="../routines/function.html">function()</a>@endhtmlonly are used in the comments
38 * to refer to DRAMA C function documention (see DramaHtml/Makefile,
39 * DramaHtml/doxygen.config and DramaHtml/filter.m4 for detials)
40 *
41
42
43 */
44#ifdef GIT_MODULE
45#define DNOCONST 0
46#endif
47/*
48 * Include file for Git module
49 */
50
51#include "DitsTypes.h" /* For DitsActionHandlerType and drama.h */
52#include "sds.h" /* For SdsIdType */
53#include "DitsSys.h"
54#include "dul.h" /* */
55#ifdef __cplusplus
56extern "C" {
57#endif
58/*
59 * Simulation levels, taken from GIT_SPEC. Note GIT_SIM_NONE should be zero.
60 */
61 typedef enum { GIT_SIM_NONE=0, GIT_SIM_BASIC, GIT_SIM_COMMANDS,
62 GIT_SIM_STATUS, GIT_SIM_FULL } GitSimulationType;
63
64 typedef enum { GIT_MON_START, GIT_MON_FORWARD, GIT_MON_ADD,
65 GIT_MON_DELETE, GIT_MON_CANCEL } GitMonitorMsgType;
66
69 typedef struct {
70 const char * GitTrue;
71 const char * GitFalse;
73
74
75#define GIT_M_SIM_BASIC 1
76#define GIT_M_SIM_COMMANDS 2
77#define GIT_M_SIM_STATUS 4
78
79#define GIT_M_SIM_ALLLEVELS -1 /* The way this was traditionally done */
80
81/*
82 * These (through to KEEPVALERR) must be unique mask values
83 *
84 */
85#define GIT_M_ARG_UPPER 1
86#define GIT_M_ARG_LOWER 2
87#define GIT_M_ARG_KEEPERR 4
88#define GIT_M_ARG_ABBREV 8
89#define GIT_M_ARG_LASTBIT 0x10
90#define GIT_M_ARG_KEEPVALERR 0x20 /* NOTE - was diffent (and wrong) value before version 3.78 */
91
92#define GIT_ARG_LMAX 20
93
94
95DPUBLIC DVOID GitActivate (
96 DCONSTV SdsIdType parsysid,
97 StatusType *status);
98DPUBLIC int GitSimulation (
99 DCONSTV char * DCONSTR exName,
100 DCONSTV int levels,
101 GitSimulationType * DCONSTR simulation,
102 float * DCONSTR timebase,
103 StatusType * DCONSTR status);
104
105DPUBLIC DVOID GitParEnvGetS(
106 DCONSTV char * DCONSTR pName,
107 DCONSTV char * DCONSTR eName,
108 DCONSTV char * DCONSTR badVal,
109 DCONSTV char * DCONSTR defVal,
110 DCONSTV int actValLen,
111 char * DCONSTR actVal,
112 StatusType * DCONSTR status);
113DPUBLIC int GitEnvGetS(
114 DCONSTV char * name,
115 DCONSTV int valLen,
116 char *val,
117 StatusType *status);
118 DPUBLIC DVOID GitArgGetS (
119 DCONSTV SdsIdType id,
120 DCONSTV char * name,
121 DCONSTV int position,
122 DCONSTV char *values[],
123 DCONSTV char *defVal,
124 DCONSTV int flags,
125 DCONSTV int actValLen ,
126 char * actValue,
127 int *index,
128 StatusType * status);
129DPUBLIC DVOID GitArgGetI (
130 DCONSTV SdsIdType id,
131 DCONSTV char *name,
132 DCONSTV int position,
133 DCONSTV long int range[],
134 DCONSTV long int defVal,
135 DCONSTV int flags,
136 long int * actValue,
137 StatusType *status);
138
139DPUBLIC DVOID GitArgGetD (
140 DCONSTV SdsIdType id,
141 DCONSTV char *name,
142 DCONSTV int position,
143 DCONSTV double range[],
144 DCONSTV double defVal,
145 DCONSTV int flags,
146 double * actValue,
147 StatusType *status);
148
149DPUBLIC DVOID GitArgGetL (
150 DCONSTV SdsIdType id,
151 DCONSTV char *name,
152 DCONSTV int position,
153 DCONSTV GitLogStrType strings[],
154 DCONSTV long int defVal,
155 DCONSTV int flags,
156 long int * actValue,
157 StatusType *status);
158
159DPUBLIC DVOID GitArgNamePos (
160 DCONSTV SdsIdType id,
161 DCONSTV char *name,
162 DCONSTV int position,
163 SdsIdType *argid,
164 StatusType *status);
165
166DPUBLIC DVOID GitArgNamePos2 (
167 DCONSTV SdsIdType id,
168 DCONSTV char *name,
169 DCONSTV int position,
170 DCONSTV int flags,
171 SdsIdType *argid,
172 StatusType *status);
173
174
175DPUBLIC DVOID GitPathGetInit(
176 DCONSTV char * DCONSTV name,
177 int MessageBytes,
178 int MaxMessages,
179 int ReplyBytes,
180 int MaxReplies,
181 int timeout,
182 DitsActionRoutineType handler,
183 DVOIDP client_data,
184 StatusType *status);
185DPUBLIC DVOID GitPathGetComp(
186 DitsPathType *path,
187 DVOIDP * client_data,
188 StatusType *status);
189
190
191DPUBLIC DVOID GitTpiInit (StatusType *status);
192DPUBLIC DVOID GitTpiPut (
193 DCONSTV int key,
194 DVOIDP item,
195 StatusType *status);
196DPUBLIC DVOID GitTpiGet (
197 DCONSTV int key,
198 DVOIDP * item,
199 StatusType *status);
200DPUBLIC DVOID GitTpiDelete (
201 DCONSTV int key,
202 StatusType *status);
203
204DPUBLIC DVOID GitArgGetStruct (
205 DCONSTV SdsIdType id,
206 DCONSTV char *name,
207 DCONSTV int position,
208 DCONSTV char *defVal,
209 int actNameLen,
210 char * actName,
211 SdsIdType * actValue,
212 StatusType *status);
213
214DPUBLIC DVOID GitPutDelay(
215 double delay,
216 StatusType *status);
217DPUBLIC DVOID GitPutDelayPar(
218 DCONSTV char * parameter,
219 StatusType *status);
220
221
222DPUBLIC DVOID GitTimer(StatusType *status);
223DPUBLIC DVOID GitTimerArgExtract(DVOIDP ClientData, const SdsIdType InArg,
224 SdsIdType * DCONSTR OutArg,
225 StatusType * DCONSTR status);
226
227
228typedef DVOID (*GitMonitorStartedType)(int id,
229 DVOIDP client_data,
230 StatusType *status);
231typedef DVOID (*GitMonitorChangedType)(
232 char * name,
233 SdsCodeType type,
234 DVOIDP value,
235 DVOIDP client_data,
236 StatusType *status);
237typedef DVOID (*GitMonitorResponseType)(
238 DVOIDP client_data,
239 StatusType *status);
240
241typedef DVOID (*GitTimerArgRoutineType)(
242 DVOIDP ClientData,
243 SdsIdType InArg, SdsIdType *OutArg,
244 StatusType *status);
245
246
247/*
248 * Can only define these prototypes in gitmonitor.c if stdarg.h is available.
249 */
250
251#if (!defined(GITMONITORC) || defined(DSTDARG_OK)) && defined(DPROTOTYPES_OK)
252 DPUBLIC DVOID GitMonitorStart(
253 DitsPathType path,
254 GitMonitorStartedType Started,
255 GitMonitorChangedType Changed,
256 GitMonitorResponseType Completed,
257 GitMonitorResponseType Unexpected,
258 DVOIDP client_data,
259 int count,
260 StatusType *status, ...);
261 DPUBLIC DVOID GitMonitorStartF(
262 DitsPathType path,
263 int Flags,
264 GitMonitorStartedType Started,
265 GitMonitorChangedType Changed,
266 GitMonitorResponseType Completed,
267 GitMonitorResponseType Unexpected,
268 DVOIDP client_data,
269 int count,
270 StatusType *status, ...);
271 DPUBLIC DVOID GitMonitorForward(
272 DitsPathType path,
273 DCONSTV char * task,
274 DCONSTV char * action,
275 GitMonitorStartedType Started,
276 GitMonitorResponseType Completed,
277 GitMonitorResponseType Unexpected,
278 DVOIDP client_data,
279 int count,
280 StatusType *status, ...);
281
282 DPUBLIC DVOID GitMonitorMessage(
283 int id,
284 DitsPathType path,
285 GitMonitorMsgType type,
286 int count,
287 DitsTransIdType * transid,
288 StatusType *status,...);
289
290#elif !defined(GITMONITORC)
291 DPUBLIC DVOID GitMonitorStart();
292 DPUBLIC DVOID GitMonitorStartF();
293 DPUBLIC DVOID GitMonitorForward();
294 DPUBLIC DVOID GitMonitorChange();
295#endif
296
297
298/*
299 * Structures used by GitTimer.
300 */
301 typedef struct {
302 char ActionName[DITS_C_NAMELEN];
303 GitTimerArgRoutineType ArgCreateRoutine;
304 DVOIDP ClientData;
305 SdsIdType Arg; /* Argument for this action */
306
307 /* Info private to GitTimer follows */
308 DitsGsokMessageType _Message; /* Message to send */
310
311 typedef struct {
312 char TaskName[DITS_C_NAMELEN]; /* Task involved */
313 int SeqCount; /* Number of elements in Sequence */
314 GitTimerDetailsType *SequenceDetails; /* Sequence definitons */
315 DitsPathInfoType Buffers; /* Message buffer sizes */
316 /* Info private to GitTimer follows */
317 int _Current; /* Current in sequence */
318 long _Count; /* Number of repeats to do */
319 int _Done; /* Number of repeats done; */
320 DitsPathType _Path; /* Path to task involved */
321 IMP_AbsTime _StartTime; /* Start time */
322 } GitTimerType;
323
324
325#ifdef __cplusplus
326} /* extern "C" */
327/*
328 * C++ only section
329 *
330 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
331 *
332 * Here is a C++ interface to Git.
333 *
334 * First, A Class which defines flags used in the rest of this module.
335 */
336#include "arg.h"
337
346DPUBLICCLASS Git {
347 public:
348 enum {
349 Upper=GIT_M_ARG_UPPER,
350 Lower=GIT_M_ARG_LOWER,
351 KeepErr=GIT_M_ARG_KEEPERR,
352 Abbrev = GIT_M_ARG_ABBREV,
353 LastBit=GIT_M_ARG_LASTBIT,
358 KeepValErr=GIT_M_ARG_KEEPVALERR
362 };
363};
364
378DPUBLICCLASS GitEnum : public Git {
379 protected:
388 virtual void SetValue(const unsigned int) = 0;
400 virtual const char * const * Lookup() = 0;
401 public:
404 virtual ~GitEnum() {};
419 void Get(const SdsId& Id,
420 const char * const Name,
421 const int Position,
422 StatusType *status,
423 const char *Default=0,
424 const int Flags = Git::Upper|Git::Abbrev)
425 {
426 char string[100];
427 int index;
428 GitArgGetS((SdsIdType)Id,Name,Position,(const char **)Lookup(),
429 Default,
430 Flags,sizeof(string),string,&index,status);
431 SetValue(index);
432 };
433
434};
460DPUBLICCLASS GitBool : public Git {
461 private:
462 bool value;
463 static const GitLogStrType lookupTable[];
464 protected:
477 virtual const GitLogStrType * Lookup() {
478 return lookupTable;
479 }
480 public:
485 value = false;
486 }
503 GitBool ( /*Constructor with automatic Get */
504 const SdsId& Id,
505 const char * const Name,
506 const int Position,
507 StatusType * const status,
508 const bool Default = false,
509 const int Flags = (Git::Upper|Git::Abbrev))
510 {
511 value = false;
512 Get(Id,Name,Position,status,Default,Flags);
513 }
516 virtual ~GitBool() {}; /* Destructor for inheritors */
531 virtual void Get( /* Get value from Sds structure */
532 const SdsId& Id,
533 const char * const Name,
534 const int Position,
535 StatusType * const status,
536 const bool Default = false,
537 const int Flags = (Git::Upper|Git::Abbrev))
538 {
539 long int actValue;
540 GitArgGetL((SdsIdType)Id,Name,Position,Lookup(),Default,
541 Flags,&actValue,status);
542 value = actValue ? true : false;
543 };
546 operator int() const {
547 return ((int)(value));
548 };
551 operator bool() const {
552 return value;
553 };
554
555};
573DPUBLICCLASS GitReal : public Git {
574 private:
575 double value;
576
577 protected:
593 virtual const double * Range() { return 0; };
594 public:
599 GitReal(const double def = 0.0) { /* Basic constructor */
600 value = def;
601 }
617 GitReal ( /*Constructor with automatic Get */
618 const SdsId& Id,
619 const char * const Name,
620 const int Position,
621 StatusType * const status,
622 const double Default = 0.0,
623 const int Flags = 0)
624 {
625 value = 0.0;
626 Get(Id,Name,Position,status,Default,Flags);
627 }
630 virtual ~GitReal() {}; /* Destructor for inheritors */
645 virtual void Get( /* Get value from Sds structure */
646 const SdsId& Id,
647 const char * const Name,
648 const int Position,
649 StatusType * const status,
650 const double Default = 0.0,
651 const int Flags = 0)
652 {
653 GitArgGetD((SdsIdType)Id,Name,Position,Range(),Default,
654 Flags,&value,status);
655 };
658 operator double() const {
659 return (value);
660 };
663 operator float() const {
664 return (value);
665 };
666
667};
668
685DPUBLICCLASS GitInt : public Git {
686 private:
687 long int value;
688
689 protected:
705 virtual const long int * Range() { return 0; };
706 public:
711 GitInt(const long int def = 0) { /* Basic constructor */
712 value = def;
713 }
728 GitInt ( /*Constructor with automatic Get */
729 const SdsId& Id,
730 const char * const Name,
731 const int Position,
732 StatusType * const status,
733 const long int Default = 0,
734 const int Flags = 0)
735 {
736 value = 0;
737 Get(Id,Name,Position,status,Default,Flags);
738 }
741 virtual ~GitInt() {}; /* Destructor for inheritors */
756 virtual void Get( /* Get value from Sds structure */
757 const SdsId& Id,
758 const char * const Name,
759 const int Position,
760 StatusType * const status,
761 const long int Default = 0,
762 const int Flags = 0)
763 {
764 GitArgGetI((SdsIdType)Id,Name,Position,Range(),Default,
765 Flags,&value,status);
766 };
768 operator long int() const {
769 return (value);
770 };
771
772};
773
774#endif
775#endif
A C++ Interface to the SDS Arg library.
Definition arg.h:263
virtual void Get(const SdsId &Id, const char *const Name, const int Position, StatusType *const status, const bool Default=false, const int Flags=(Git::Upper|Git::Abbrev))
Get the value of the object from an SDS struture.
Definition Git.h:531
GitBool()
Simple constructor with a default value of false.
Definition Git.h:484
GitBool(const SdsId &Id, const char *const Name, const int Position, StatusType *const status, const bool Default=false, const int Flags=(Git::Upper|Git::Abbrev))
Constructor with the initial value set from an SDS structure.
Definition Git.h:503
virtual const GitLogStrType * Lookup()
Return a pointer to an array of enum strings equivalents.
Definition Git.h:477
virtual ~GitBool()
Destructor.
Definition Git.h:516
A class which reads logical values from SDS argument structures.
Definition Git.h:460
virtual const char *const * Lookup()=0
Return a pointer to an array of enum strings equivalents.
virtual void SetValue(const unsigned int)=0
Set the value of the object.
void Get(const SdsId &Id, const char *const Name, const int Position, StatusType *status, const char *Default=0, const int Flags=Git::Upper|Git::Abbrev)
Get the value of the object from an SDS struture.
Definition Git.h:419
virtual ~GitEnum()
Destructor.
Definition Git.h:404
A class which reads Enumerated values from a SDS argument structures.
Definition Git.h:378
virtual void Get(const SdsId &Id, const char *const Name, const int Position, StatusType *const status, const long int Default=0, const int Flags=0)
Get the value of the object from an SDS struture.
Definition Git.h:756
virtual const long int * Range()
Function which returns sets the range.
Definition Git.h:705
virtual ~GitInt()
Destructor.
Definition Git.h:741
GitInt(const long int def=0)
Simple constructor with a default value specified.
Definition Git.h:711
GitInt(const SdsId &Id, const char *const Name, const int Position, StatusType *const status, const long int Default=0, const int Flags=0)
Constructor with the initial value set from an SDS structure.
Definition Git.h:728
A class which reads integer values from an SDS argument structure.
Definition Git.h:685
virtual const double * Range()
Method which returns sets the range.
Definition Git.h:593
GitReal(const SdsId &Id, const char *const Name, const int Position, StatusType *const status, const double Default=0.0, const int Flags=0)
Constructor with the initial value set from an SDS structure.
Definition Git.h:617
GitReal(const double def=0.0)
Simple constructor with a default value specified.
Definition Git.h:599
virtual ~GitReal()
Destructor.
Definition Git.h:630
virtual void Get(const SdsId &Id, const char *const Name, const int Position, StatusType *const status, const double Default=0.0, const int Flags=0)
Get the value of the object from an SDS struture.
Definition Git.h:645
A class which reads real values from an SDS argument structure.
Definition Git.h:573
@ Abbrev
Allow abbreviations
Definition Git.h:352
@ Upper
Convert strings to upper case.
Definition Git.h:349
The GitArgGet flags set up appropriately for C++.
Definition Git.h:346
A C++ Interface to the handling SDS structures.
Definition sds.h:761
const char * GitFalse
The string for FALSE.
Definition Git.h:71
const char * GitTrue
The string for TRUE.
Definition Git.h:70
A type used to store true and false string equivalent values.
Definition Git.h:69
Definition Git.h:301
Definition Git.h:311