ngc 1.4.0
 
Loading...
Searching...
No Matches
ngcbPARAM.hpp
Go to the documentation of this file.
1
7#ifndef ngcbPARAM_H
8#define ngcbPARAM_H
9
10
11#ifndef __cplusplus
12#error This is a C++ include file and cannot be used from plain C
13#endif
14
15#include <ngc/core/ngcb.h>
17
18/*
19 * Parameter type definitions
20 */
21#define ngcbPARAM_CHAR 0 //< Logical ('T' or 'F' or 0 or 1)
22#define ngcbPARAM_INT 1 //< 32-bit signed integer
23#define ngcbPARAM_FLOAT 2 //< 32-bit floating point
24#define ngcbPARAM_DOUBLE 3 //< 64-bit floating point
25#define ngcbPARAM_STRING 4 //< String
26
27/*
28 * Some flags for ctrl-list
29 */
30#define ngcbPARAM_FLAG_FREE 31 //< Free parameter
31#define ngcbPARAM_FLAG_CFG 30 //< Front-end configuration parameter
32#define ngcbPARAM_FLAG_MODE 29 //< Read-mode specific parameter
33
35#define ngcbPARAM_MAX_STRING 255
36
40class ngcbPARAM {
41public:
43 unsigned int ctrlList;
44
46 unsigned int acqList;
47
49 char name[64];
50
52 char alias[64];
53
55 char format[16];
56
58 int fits;
59
61 char comment[44];
62
64 char unit[8];
65
68
70 bool operator ==(const ngcbPARAM& other) const;
71
73 bool operator !=(const ngcbPARAM& other) const;
74
76 ngcbPARAM &operator=(const ngcbPARAM &other);
77
79 ngcbPARAM(const ngcbPARAM &other);
80
82 ngcbPARAM();
83
85 explicit ngcbPARAM(const char *paramName);
86
88 ngcbPARAM(const char *paramName, char initVal);
89
91 ngcbPARAM(const char *paramName, int initVal);
92
94 ngcbPARAM(const char *paramName, float initVal);
95
97 ngcbPARAM(const char *paramName, double initVal);
98
100 ngcbPARAM(const char *paramName, const char *initVal);
101
103 ngcbPARAM(const char *paramName, const char *initVal, int type);
104
106 virtual ~ngcbPARAM();
107
109 int Comp(ngcbPARAM &p);
110
112 int Changed();
113
115 void Alias(const char *a);
116
118 int Type();
119
121 void Type(int newType);
122
124 int Set(char newValue);
125
127 int Set(int newValue);
128
130 int Set(float newValue);
131
133 int Set(double newValue);
134
136 int Set(const char *newValue);
137
139 char ValChar() const;
140
142 int ValInt() const;
143
145 float ValFloat() const;
146
148 double ValDouble() const;
149
151 const char *ValString();
152
154 const char *Get();
155
157 void Get(char *stringVal) const;
158
160 void Store();
161
163 void Restore();
164
165protected:
166
167private:
169 void Init_();
170
172 void *value_;
173
175 void *tmpValue_;
176
178 int type_;
179
181 int size_;
182
184 int changed_;
185
187 char stringVal_[ngcbPARAM_MAX_STRING + 1];
188
190 char tmpString_[ngcbPARAM_MAX_STRING + 1];
191
193 int Comp_(const ngcbPARAM &p) const;
194};
195
196
201public:
204
207
210
212 ngcbPARAM_LIST(ngcbPARAM *newParam, int noDelete);
213
215 virtual ~ngcbPARAM_LIST();
216
219
221 ngcbPARAM *Add(ngcbPARAM *newParam, int noDelete = 1);
222
224 ngcbPARAM *Add(const char *paramName);
225
227 ngcbPARAM *Add(const char *paramName, char initVal);
228
230 ngcbPARAM *Add(const char *paramName, int initVal);
231
233 ngcbPARAM *Add(const char *paramName, float initVal);
234
236 ngcbPARAM *Add(const char *paramName, double initVal);
237
239 ngcbPARAM *Add(const char *paramName, const char *initVal);
240
242 ngcbPARAM *Add(const char *paramName, const char *initVal, int type);
243
245 void Remove(ngcbPARAM *item);
246
248 void Remove(const char *paramName);
249
251 void Clear();
252
254 void Insert(ngcbPARAM_LIST &other);
255
257 ngcbPARAM *Get(const char *paramName);
258
260 int Set(const char *paramName, char paramValue);
261
263 int Set(const char *paramName, int paramValue);
264
266 int Set(const char *paramName, float paramValue);
267
269 int Set(const char *paramName, double paramValue);
270
272 int Set(const char *paramName, const char *paramValue);
273
275 int ValChar(const char *paramName, char *paramValue);
276
278 int ValInt(const char *paramName, int *paramValue);
279
281 int ValFloat(const char *paramName, float *paramValue);
282
284 int ValDouble(const char *paramName, double *paramValue);
285
287 int ValString(const char *paramName, char *paramValue);
288
290 void ClrAcqList(int instance);
291
293 void ClrCtrlList(int instance);
294
296 int Load(char **paramBuf, size_t size, char *erms);
297
299 int Load(const char *paramBuf, char *erms);
300
302 int Load(const char *fileName, const char *mask, char *erms);
303
305 void Options(int argc, char *argv[]);
306
308 void Print(FILE *s = NULL);
309
311 void Print(char *s);
312
313protected:
314
315private:
317 ngcbPARAM_LIST *first_;
318
320 ngcbPARAM_LIST *current_;
321
323 int noDelete_;
324
326 int Load_(const char *fileName, const char *mask, int *inclLevel,
327 char *erms);
328};
329
330
331#endif
int ValInt(const char *paramName, int *paramValue)
Get 32-bit integer value by name.
Definition ngcbPARAM_LIST.cpp:400
ngcbPARAM_LIST()
Constructor.
Definition ngcbPARAM_LIST.cpp:27
void ClrCtrlList(int instance)
Detach controller module from parameter list.
Definition ngcbPARAM_LIST.cpp:485
ngcbPARAM_LIST * next
Next list.
Definition ngcbPARAM.hpp:206
int Load(char **paramBuf, size_t size, char *erms)
Load parameter list from string array.
Definition ngcbPARAM_LIST.cpp:545
virtual ~ngcbPARAM_LIST()
Destructor.
Definition ngcbPARAM_LIST.cpp:48
ngcbPARAM_LIST * First()
Get list entry point.
Definition ngcbPARAM_LIST.cpp:59
int ValChar(const char *paramName, char *paramValue)
Get character value by name.
Definition ngcbPARAM_LIST.cpp:386
void Options(int argc, char *argv[])
Load parameter list from command line options.
Definition ngcbPARAM_LIST.cpp:513
void Insert(ngcbPARAM_LIST &other)
Insert content from other list.
Definition ngcbPARAM_LIST.cpp:192
int ValDouble(const char *paramName, double *paramValue)
Get 64-bit floating point value by name.
Definition ngcbPARAM_LIST.cpp:428
ngcbPARAM * Add(ngcbPARAM *newParam, int noDelete=1)
Add external parameter object to list.
Definition ngcbPARAM_LIST.cpp:107
void Print(FILE *s=NULL)
Print parameter list to stream.
Definition ngcbPARAM_LIST.cpp:242
int ValFloat(const char *paramName, float *paramValue)
Get 32-bit floating point value by name.
Definition ngcbPARAM_LIST.cpp:414
ngcbPARAM * Get(const char *paramName)
Get parameter object by name.
Definition ngcbPARAM_LIST.cpp:308
void Clear()
Remove all parameters.
Definition ngcbPARAM_LIST.cpp:135
void ClrAcqList(int instance)
Detach acquisition module from parameter list.
Definition ngcbPARAM_LIST.cpp:456
int Set(const char *paramName, char paramValue)
Set character value by name.
Definition ngcbPARAM_LIST.cpp:326
void Remove(ngcbPARAM *item)
Remove parameter by object pointer.
Definition ngcbPARAM_LIST.cpp:148
int ValString(const char *paramName, char *paramValue)
Get string value by name.
Definition ngcbPARAM_LIST.cpp:442
ngcbPARAM * param
Parameter in the list.
Definition ngcbPARAM.hpp:203
Definition ngcbPARAM.hpp:40
char unit[8]
Optional parameter unit.
Definition ngcbPARAM.hpp:64
unsigned int ctrlList
List of controller modules where parameter is used.
Definition ngcbPARAM.hpp:43
float ValFloat() const
Get parameter value converted to 32-bit floating point format.
Definition ngcbPARAM.cpp:1132
int Comp(ngcbPARAM &p)
Compare parameter values.
Definition ngcbPARAM.cpp:382
ngcbPARAM()
Constructors for basic container.
Definition ngcbPARAM.cpp:92
ngcbPARAM & operator=(const ngcbPARAM &other)
Operator =.
Definition ngcbPARAM.cpp:38
int Set(char newValue)
Set parameter value converted to character format.
Definition ngcbPARAM.cpp:552
double ValDouble() const
Get parameter value converted to 64-bit floating point format.
Definition ngcbPARAM.cpp:1170
int Changed()
Check for change since last call.
Definition ngcbPARAM.cpp:375
const char * Get()
Get parameter value converted to string format.
Definition ngcbPARAM.cpp:507
virtual ~ngcbPARAM()
Destructor.
Definition ngcbPARAM.cpp:248
char ValChar() const
Get parameter value converted to character format.
Definition ngcbPARAM.cpp:1007
char format[16]
Parameter format for printf etc.
Definition ngcbPARAM.hpp:55
bool operator==(const ngcbPARAM &other) const
Comparison operator ==.
Definition ngcbPARAM.cpp:27
void Store()
Store to temporary buffer.
Definition ngcbPARAM.cpp:411
void Alias(const char *a)
Set alias name.
Definition ngcbPARAM.cpp:276
ngcbPARAM(const ngcbPARAM &other)
Copy constructor.
Definition ngcbPARAM.cpp:67
int ValInt() const
Get parameter value converted to 32-bit integer format.
Definition ngcbPARAM.cpp:1065
char comment[44]
Optional parameter comment for FITS-header.
Definition ngcbPARAM.hpp:61
char name[64]
Parameter name.
Definition ngcbPARAM.hpp:49
int attribute
Storage space for application specific attributes.
Definition ngcbPARAM.hpp:67
int Type()
Get parameter type.
Definition ngcbPARAM.cpp:281
int fits
Flag to put paramter into FITS-header.
Definition ngcbPARAM.hpp:58
bool operator!=(const ngcbPARAM &other) const
Comparison operator !=.
Definition ngcbPARAM.cpp:33
unsigned int acqList
List of acquisition processes where parameter is used.
Definition ngcbPARAM.hpp:46
const char * ValString()
Get parameter value converted to string format.
Definition ngcbPARAM.cpp:1208
void Restore()
Restore from temporary buffer.
Definition ngcbPARAM.cpp:421
char alias[64]
Parameter alias name.
Definition ngcbPARAM.hpp:52
#define ngcbPARAM_MAX_STRING
Maximum string length.
Definition ngcbPARAM.hpp:35