ngc 1.4.0
 
Loading...
Searching...
No Matches
ngcbATTR.hpp
Go to the documentation of this file.
1
7#ifndef ngcbATTR_H
8#define ngcbATTR_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>
16
20#define ngcbDB_MAX_ATTR (1024 * 128)
21
25#define ngcbDB_POOL_SIZE (1024 * 1024 * 4)
26
27/*
28 * Attribute data types
29 */
30#define ngcbATTR_UNKNOWN 0 //< unknown attribute
31#define ngcbATTR_CHAR 1 //< 8 bit signed char
32#define ngcbATTR_UCHAR 2 //< 8 bit unsigned char
33#define ngcbATTR_SHORT 3 //< 16 bit signed short integer
34#define ngcbATTR_USHORT 4 //< 16 bit unsigned short integer
35#define ngcbATTR_INT 5 //< 32 bit signed integer
36#define ngcbATTR_UINT 6 //< 32 bit unsigned integer
37#define ngcbATTR_FLOAT 7 //< 32 bit floating point
38#define ngcbATTR_DOUBLE 8 //< 64 bit floating point
39#define ngcbATTR_STRING 9 //< string
40#define ngcbATTR_LINT 10 //< signed long integer (32 or 64 bit - ssize_t)
41#define ngcbATTR_LUINT 11 //< unsigned long integer (32 or 64 bit - size_t)
42#define ngcbATTR_INT64 12 //< 64 bit signed integer
43#define ngcbATTR_UINT64 13 //< 64 bit unsigned integer
44
45/*
46 * String types
47 */
48typedef char ngcb_attr_s256[256]; //< 256 bytes string
49typedef char ngcb_attr_s128[128]; //< 128 bytes string
50typedef char ngcb_attr_s64[64]; //< 64 bytes string
51typedef char ngcb_attr_s48[48]; //< 48 bytes string
52typedef char ngcb_attr_s32[32]; //< 32 bytes string
53typedef char ngcb_attr_s20[20]; //< 20 bytes string
54typedef char ngcb_attr_s16[16]; //< 16 bytes string
55typedef char ngcb_attr_s12[12]; //< 12 bytes string
56typedef char ngcb_attr_s8[8]; //< 8 bytes string
57typedef char ngcb_attr_s4[4]; //< 4 bytes string
58
62class ngcbATTR {
63public:
65 char name[256];
66
69
71 int delay;
72
74 ngcbATTR(const char *n, void *a, int rs, int nr = 1);
75
77 explicit ngcbATTR(const char *n, ngcb_attr_s256 *a, int nr = 1);
78
80 explicit ngcbATTR(const char *n, ngcb_attr_s128 *a, int nr = 1);
81
83 explicit ngcbATTR(const char *n, ngcb_attr_s64 *a, int nr = 1);
84
86 explicit ngcbATTR(const char *n, ngcb_attr_s48 *a, int nr = 1);
87
89 explicit ngcbATTR(const char *n, ngcb_attr_s32 *a, int nr = 1);
90
92 explicit ngcbATTR(const char *n, ngcb_attr_s20 *a, int nr = 1);
93
95 explicit ngcbATTR(const char *n, ngcb_attr_s16 *a, int nr = 1);
96
98 explicit ngcbATTR(const char *n, ngcb_attr_s12 *a, int nr = 1);
99
101 explicit ngcbATTR(const char *n, ngcb_attr_s8 *a, int nr = 1);
102
104 explicit ngcbATTR(const char *n, ngcb_attr_s4 *a, int nr = 1);
105
107 explicit ngcbATTR(const char *n, char *a, int nr = 1);
108
110 explicit ngcbATTR(const char *n, unsigned char *a, int nr = 1);
111
113 ngcbATTR(const char *n, short *a, int nr = 1);
114
116 ngcbATTR(const char *n, unsigned short *a, int nr = 1);
117
119 ngcbATTR(const char *n, int *a, int nr = 1);
120
122 ngcbATTR(const char *n, unsigned int *a, int nr = 1);
123
125 ngcbATTR(const char *n, float *a, int nr = 1);
126
128 ngcbATTR(const char *n, double *a, int nr = 1);
129
131 ngcbATTR(const char *n, long int *a, int nr = 1);
132
134 ngcbATTR(const char *n, unsigned long *a, int nr = 1);
135
137 ngcbATTR(const char *n, long long int *a, int nr = 1);
138
140 ngcbATTR(const char *n, unsigned long long int *a, int nr = 1);
141
143 virtual ~ngcbATTR();
144
146 void Pool(char *p);
147
149 int Changed();
150
152 int Update();
153
155 int Type();
156
158 int Size();
159
161 int RecordSize();
162
164 int NumRecord();
165
167 void *Addr();
168
170 int Write();
171
173 virtual int Export();
174
175protected:
176
177private:
179 void *value_;
180
182 int type_;
183
185 int size_;
186
188 int recordSize_;
189
191 int numRecord_;
192
194 void *addr_;
195
197 char *pool_;
198
200 void Init_(const char *n, void *a, int nr);
201};
202
206class ngcbDB {
207public:
210
212 ngcbDB &operator=(const ngcbDB &other);
213
215 ngcbDB(const ngcbDB &other);
216
218 ngcbDB();
219
221 explicit ngcbDB(char *p);
222
224 virtual ~ngcbDB();
225
227 void PoolInit();
228
230 size_t PoolSize();
231
233 const char *Pool();
234
236 void DelAttr();
237
239 void DelAttr(int idx);
240
242 int Add(ngcbATTR *newAttr);
243
245 void WaitState(int value);
246
248 void WaitTime(int value);
249
251 void InitDelay(int value);
252
254 int Update(int idx);
255
257 int Update();
258
260 int Export();
261
262protected:
263
264private:
266 ngcbATTR **attr_;
267
269 int numAttr_;
270
272 char *pool_;
273
275 int native_;
276
278 int waitState_;
279
281 int waitTime_;
282
284 int delayTime_;
285
287 void Init_();
288};
289
290#endif
Definition ngcbATTR.hpp:62
char name[256]
Attribute name.
Definition ngcbATTR.hpp:65
int Update()
Update attribute if changed.
Definition ngcbATTR.cpp:196
ngcbATTR(const char *n, void *a, int rs, int nr=1)
Constructor for generic types.
Definition ngcbATTR.cpp:13
int Size()
Storage size of the attribute.
Definition ngcbATTR.cpp:203
int * waitState
Pointer to wait-state counter for high latency databases.
Definition ngcbATTR.hpp:68
int delay
Initialization delay in microseconds.
Definition ngcbATTR.hpp:71
int RecordSize()
Record size of the attribute.
Definition ngcbATTR.cpp:205
virtual int Export()
Attribute export function.
Definition ngcbATTR.cpp:230
void Pool(char *p)
Set attribute pool.
Definition ngcbATTR.cpp:175
virtual ~ngcbATTR()
Destructor.
Definition ngcbATTR.cpp:173
int Write()
Write attribute.
Definition ngcbATTR.cpp:211
void * Addr()
Physical address of the attribute.
Definition ngcbATTR.cpp:209
int Type()
Type of the attribute.
Definition ngcbATTR.cpp:201
int Changed()
Check if attribute has changed.
Definition ngcbATTR.cpp:177
int NumRecord()
Number of records.
Definition ngcbATTR.cpp:207
void PoolInit()
Initialize attribute pool.
Definition ngcbDB.cpp:204
int Add(ngcbATTR *newAttr)
Add attribute.
Definition ngcbDB.cpp:234
ngcbDB & operator=(const ngcbDB &other)
Operator =.
Definition ngcbDB.cpp:13
void WaitTime(int value)
Set wait time (microseconds)
Definition ngcbDB.cpp:278
size_t PoolSize()
Size of the attribute pool.
Definition ngcbDB.cpp:209
virtual ~ngcbDB()
Destructor.
Definition ngcbDB.cpp:186
int waitState
Wait state for high latency databases.
Definition ngcbATTR.hpp:209
const char * Pool()
Return attribute pool.
Definition ngcbDB.cpp:211
ngcbDB()
Constructor.
Definition ngcbDB.cpp:148
void WaitState(int value)
Set number of states before wait.
Definition ngcbDB.cpp:272
void InitDelay(int value)
Set initialization delay (microseconds)
Definition ngcbDB.cpp:283
int Update()
Update all attributes which have changed.
Definition ngcbDB.cpp:294
void DelAttr()
Delete all attributes.
Definition ngcbDB.cpp:213
int Export()
Export all attributes.
Definition ngcbDB.cpp:313
ngcbDB(const ngcbDB &other)
Copy constructor.
Definition ngcbDB.cpp:83
char ngcb_attr_s64[64]
Definition ngcbATTR.hpp:50
char ngcb_attr_s20[20]
Definition ngcbATTR.hpp:53
char ngcb_attr_s8[8]
Definition ngcbATTR.hpp:56
char ngcb_attr_s12[12]
Definition ngcbATTR.hpp:55
char ngcb_attr_s48[48]
Definition ngcbATTR.hpp:51
char ngcb_attr_s256[256]
Definition ngcbATTR.hpp:48
char ngcb_attr_s128[128]
Definition ngcbATTR.hpp:49
char ngcb_attr_s32[32]
Definition ngcbATTR.hpp:52
char ngcb_attr_s4[4]
Definition ngcbATTR.hpp:57
char ngcb_attr_s16[16]
Definition ngcbATTR.hpp:54