ngc 1.5.0
 
Loading...
Searching...
No Matches
ngcbPARAM.hpp
Go to the documentation of this file.
1
8#ifndef ngcbPARAM_H
9#define ngcbPARAM_H
10
11
12#ifndef __cplusplus
13#error This is a C++ include file and cannot be used from plain C
14#endif
15
16#include <ngc/core/ngcb.h>
18
19/*
20 * Parameter type definitions
21 */
22#define ngcbPARAM_CHAR 0 //< Logical ('T' or 'F' or 0 or 1)
23#define ngcbPARAM_INT 1 //< 32-bit signed integer
24#define ngcbPARAM_FLOAT 2 //< 32-bit floating point
25#define ngcbPARAM_DOUBLE 3 //< 64-bit floating point
26#define ngcbPARAM_STRING 4 //< String
27
28/*
29 * Some flags for ctrl-list
30 */
31#define ngcbPARAM_FLAG_FREE 31 //< Free parameter
32#define ngcbPARAM_FLAG_CFG 30 //< Front-end configuration parameter
33#define ngcbPARAM_FLAG_MODE 29 //< Read-mode specific parameter
34
36#define ngcbPARAM_MAX_STRING 255
37
41class ngcbPARAM {
42public:
44 unsigned int ctrlList;
45
47 unsigned int acqList;
48
50 char name[64];
51
53 char alias[64];
54
56 char format[16];
57
59 int fits;
60
62 char comment[44];
63
65 char unit[8];
66
69
71 bool operator ==(const ngcbPARAM& other) const;
72
74 bool operator !=(const ngcbPARAM& other) const;
75
77 ngcbPARAM &operator=(const ngcbPARAM &other);
78
80 ngcbPARAM(const ngcbPARAM &other);
81
83 ngcbPARAM();
84
86 explicit ngcbPARAM(const char *paramName);
87
89 ngcbPARAM(const char *paramName, char initVal);
90
92 ngcbPARAM(const char *paramName, int initVal);
93
95 ngcbPARAM(const char *paramName, float initVal);
96
98 ngcbPARAM(const char *paramName, double initVal);
99
101 ngcbPARAM(const char *paramName, const char *initVal);
102
104 ngcbPARAM(const char *paramName, const char *initVal, int type);
105
107 virtual ~ngcbPARAM();
108
110 int Comp(ngcbPARAM &p);
111
113 int Changed();
114
116 void Alias(const char *a);
117
119 int Type();
120
122 void Type(int newType);
123
125 int Set(char newValue);
126
128 int Set(int newValue);
129
131 int Set(float newValue);
132
134 int Set(double newValue);
135
137 int Set(const char *newValue);
138
140 char ValChar() const;
141
143 int ValInt() const;
144
146 float ValFloat() const;
147
149 double ValDouble() const;
150
152 const char *ValString();
153
155 const char *Get();
156
158 void Get(char *stringVal) const;
159
161 void Store();
162
164 void Restore();
165
166protected:
167
168private:
170 void Init_();
171
173 void *value_;
174
176 void *tmpValue_;
177
179 int type_;
180
182 int size_;
183
185 int changed_;
186
188 char stringVal_[ngcbPARAM_MAX_STRING + 1];
189
191 char tmpString_[ngcbPARAM_MAX_STRING + 1];
192
194 int Comp_(const ngcbPARAM &p) const;
195};
196
197
202public:
205
208
211
213 ngcbPARAM_LIST(ngcbPARAM *newParam, int noDelete);
214
216 virtual ~ngcbPARAM_LIST();
217
220
222 ngcbPARAM *Add(ngcbPARAM *newParam, int noDelete = 1);
223
225 ngcbPARAM *Add(const char *paramName);
226
228 ngcbPARAM *Add(const char *paramName, char initVal);
229
231 ngcbPARAM *Add(const char *paramName, int initVal);
232
234 ngcbPARAM *Add(const char *paramName, float initVal);
235
237 ngcbPARAM *Add(const char *paramName, double initVal);
238
240 ngcbPARAM *Add(const char *paramName, const char *initVal);
241
243 ngcbPARAM *Add(const char *paramName, const char *initVal, int type);
244
246 void Remove(ngcbPARAM *item);
247
249 void Remove(const char *paramName);
250
252 void Clear();
253
255 void Insert(ngcbPARAM_LIST &other);
256
258 ngcbPARAM *Get(const char *paramName);
259
261 int Set(const char *paramName, char paramValue);
262
264 int Set(const char *paramName, int paramValue);
265
267 int Set(const char *paramName, float paramValue);
268
270 int Set(const char *paramName, double paramValue);
271
273 int Set(const char *paramName, const char *paramValue);
274
276 int ValChar(const char *paramName, char *paramValue);
277
279 int ValInt(const char *paramName, int *paramValue);
280
282 int ValFloat(const char *paramName, float *paramValue);
283
285 int ValDouble(const char *paramName, double *paramValue);
286
288 int ValString(const char *paramName, char *paramValue);
289
291 void ClrAcqList(int instance);
292
294 void ClrCtrlList(int instance);
295
297 int Load(char **paramBuf, size_t size, char *erms);
298
300 int Load(const char *paramBuf, char *erms);
301
303 int Load(const char *fileName, const char *mask, char *erms);
304
306 void Options(int argc, char *argv[]);
307
309 void Print(FILE *s = NULL);
310
312 void Print(char *s);
313
314protected:
315
316private:
318 ngcbPARAM_LIST *first_;
319
321 ngcbPARAM_LIST *current_;
322
324 int noDelete_;
325
327 int Load_(const char *fileName, const char *mask, int *inclLevel,
328 char *erms);
329};
330
331
332#endif
int ValInt(const char *paramName, int *paramValue)
Get 32-bit integer value by name.
Definition ngcbPARAM_LIST.cpp:401
ngcbPARAM_LIST()
Constructor.
Definition ngcbPARAM_LIST.cpp:28
void ClrCtrlList(int instance)
Detach controller module from parameter list.
Definition ngcbPARAM_LIST.cpp:486
ngcbPARAM_LIST * next
Next list.
Definition ngcbPARAM.hpp:207
int Load(char **paramBuf, size_t size, char *erms)
Load parameter list from string array.
Definition ngcbPARAM_LIST.cpp:546
virtual ~ngcbPARAM_LIST()
Destructor.
Definition ngcbPARAM_LIST.cpp:49
ngcbPARAM_LIST * First()
Get list entry point.
Definition ngcbPARAM_LIST.cpp:60
int ValChar(const char *paramName, char *paramValue)
Get character value by name.
Definition ngcbPARAM_LIST.cpp:387
void Options(int argc, char *argv[])
Load parameter list from command line options.
Definition ngcbPARAM_LIST.cpp:514
void Insert(ngcbPARAM_LIST &other)
Insert content from other list.
Definition ngcbPARAM_LIST.cpp:193
int ValDouble(const char *paramName, double *paramValue)
Get 64-bit floating point value by name.
Definition ngcbPARAM_LIST.cpp:429
ngcbPARAM * Add(ngcbPARAM *newParam, int noDelete=1)
Add external parameter object to list.
Definition ngcbPARAM_LIST.cpp:108
void Print(FILE *s=NULL)
Print parameter list to stream.
Definition ngcbPARAM_LIST.cpp:243
int ValFloat(const char *paramName, float *paramValue)
Get 32-bit floating point value by name.
Definition ngcbPARAM_LIST.cpp:415
ngcbPARAM * Get(const char *paramName)
Get parameter object by name.
Definition ngcbPARAM_LIST.cpp:309
void Clear()
Remove all parameters.
Definition ngcbPARAM_LIST.cpp:136
void ClrAcqList(int instance)
Detach acquisition module from parameter list.
Definition ngcbPARAM_LIST.cpp:457
int Set(const char *paramName, char paramValue)
Set character value by name.
Definition ngcbPARAM_LIST.cpp:327
void Remove(ngcbPARAM *item)
Remove parameter by object pointer.
Definition ngcbPARAM_LIST.cpp:149
int ValString(const char *paramName, char *paramValue)
Get string value by name.
Definition ngcbPARAM_LIST.cpp:443
ngcbPARAM * param
Parameter in the list.
Definition ngcbPARAM.hpp:204
Definition ngcbPARAM.hpp:41
char unit[8]
Optional parameter unit.
Definition ngcbPARAM.hpp:65
unsigned int ctrlList
List of controller modules where parameter is used.
Definition ngcbPARAM.hpp:44
float ValFloat() const
Get parameter value converted to 32-bit floating point format.
Definition ngcbPARAM.cpp:1133
int Comp(ngcbPARAM &p)
Compare parameter values.
Definition ngcbPARAM.cpp:383
ngcbPARAM()
Constructors for basic container.
Definition ngcbPARAM.cpp:93
ngcbPARAM & operator=(const ngcbPARAM &other)
Operator =.
Definition ngcbPARAM.cpp:39
int Set(char newValue)
Set parameter value converted to character format.
Definition ngcbPARAM.cpp:553
double ValDouble() const
Get parameter value converted to 64-bit floating point format.
Definition ngcbPARAM.cpp:1171
int Changed()
Check for change since last call.
Definition ngcbPARAM.cpp:376
const char * Get()
Get parameter value converted to string format.
Definition ngcbPARAM.cpp:508
virtual ~ngcbPARAM()
Destructor.
Definition ngcbPARAM.cpp:249
char ValChar() const
Get parameter value converted to character format.
Definition ngcbPARAM.cpp:1008
char format[16]
Parameter format for printf etc.
Definition ngcbPARAM.hpp:56
bool operator==(const ngcbPARAM &other) const
Comparison operator ==.
Definition ngcbPARAM.cpp:28
void Store()
Store to temporary buffer.
Definition ngcbPARAM.cpp:412
void Alias(const char *a)
Set alias name.
Definition ngcbPARAM.cpp:277
ngcbPARAM(const ngcbPARAM &other)
Copy constructor.
Definition ngcbPARAM.cpp:68
int ValInt() const
Get parameter value converted to 32-bit integer format.
Definition ngcbPARAM.cpp:1066
char comment[44]
Optional parameter comment for FITS-header.
Definition ngcbPARAM.hpp:62
char name[64]
Parameter name.
Definition ngcbPARAM.hpp:50
int attribute
Storage space for application specific attributes.
Definition ngcbPARAM.hpp:68
int Type()
Get parameter type.
Definition ngcbPARAM.cpp:282
int fits
Flag to put paramter into FITS-header.
Definition ngcbPARAM.hpp:59
bool operator!=(const ngcbPARAM &other) const
Comparison operator !=.
Definition ngcbPARAM.cpp:34
unsigned int acqList
List of acquisition processes where parameter is used.
Definition ngcbPARAM.hpp:47
const char * ValString()
Get parameter value converted to string format.
Definition ngcbPARAM.cpp:1209
void Restore()
Restore from temporary buffer.
Definition ngcbPARAM.cpp:422
char alias[64]
Parameter alias name.
Definition ngcbPARAM.hpp:53
#define ngcbPARAM_MAX_STRING
Maximum string length.
Definition ngcbPARAM.hpp:36