ngc 1.5.0
 
Loading...
Searching...
No Matches
ngcbATTR.hpp
Go to the documentation of this file.
1
8#ifndef ngcbATTR_H
9#define ngcbATTR_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>
17
21#define ngcbDB_MAX_ATTR (1024 * 128)
22
26#define ngcbDB_POOL_SIZE (1024 * 1024 * 4)
27
28/*
29 * Attribute data types
30 */
31#define ngcbATTR_UNKNOWN 0 //< unknown attribute
32#define ngcbATTR_CHAR 1 //< 8 bit signed char
33#define ngcbATTR_UCHAR 2 //< 8 bit unsigned char
34#define ngcbATTR_SHORT 3 //< 16 bit signed short integer
35#define ngcbATTR_USHORT 4 //< 16 bit unsigned short integer
36#define ngcbATTR_INT 5 //< 32 bit signed integer
37#define ngcbATTR_UINT 6 //< 32 bit unsigned integer
38#define ngcbATTR_FLOAT 7 //< 32 bit floating point
39#define ngcbATTR_DOUBLE 8 //< 64 bit floating point
40#define ngcbATTR_STRING 9 //< string
41#define ngcbATTR_LINT 10 //< signed long integer (32 or 64 bit - ssize_t)
42#define ngcbATTR_LUINT 11 //< unsigned long integer (32 or 64 bit - size_t)
43#define ngcbATTR_INT64 12 //< 64 bit signed integer
44#define ngcbATTR_UINT64 13 //< 64 bit unsigned integer
45
46/*
47 * String types
48 */
49typedef char ngcb_attr_s256[256]; //< 256 bytes string
50typedef char ngcb_attr_s128[128]; //< 128 bytes string
51typedef char ngcb_attr_s64[64]; //< 64 bytes string
52typedef char ngcb_attr_s48[48]; //< 48 bytes string
53typedef char ngcb_attr_s32[32]; //< 32 bytes string
54typedef char ngcb_attr_s20[20]; //< 20 bytes string
55typedef char ngcb_attr_s16[16]; //< 16 bytes string
56typedef char ngcb_attr_s12[12]; //< 12 bytes string
57typedef char ngcb_attr_s8[8]; //< 8 bytes string
58typedef char ngcb_attr_s4[4]; //< 4 bytes string
59
63class ngcbATTR {
64public:
66 char name[256];
67
70
72 int delay;
73
75 ngcbATTR(const char *n, void *a, int rs, int nr = 1);
76
78 explicit ngcbATTR(const char *n, ngcb_attr_s256 *a, int nr = 1);
79
81 explicit ngcbATTR(const char *n, ngcb_attr_s128 *a, int nr = 1);
82
84 explicit ngcbATTR(const char *n, ngcb_attr_s64 *a, int nr = 1);
85
87 explicit ngcbATTR(const char *n, ngcb_attr_s48 *a, int nr = 1);
88
90 explicit ngcbATTR(const char *n, ngcb_attr_s32 *a, int nr = 1);
91
93 explicit ngcbATTR(const char *n, ngcb_attr_s20 *a, int nr = 1);
94
96 explicit ngcbATTR(const char *n, ngcb_attr_s16 *a, int nr = 1);
97
99 explicit ngcbATTR(const char *n, ngcb_attr_s12 *a, int nr = 1);
100
102 explicit ngcbATTR(const char *n, ngcb_attr_s8 *a, int nr = 1);
103
105 explicit ngcbATTR(const char *n, ngcb_attr_s4 *a, int nr = 1);
106
108 explicit ngcbATTR(const char *n, char *a, int nr = 1);
109
111 explicit ngcbATTR(const char *n, unsigned char *a, int nr = 1);
112
114 ngcbATTR(const char *n, short *a, int nr = 1);
115
117 ngcbATTR(const char *n, unsigned short *a, int nr = 1);
118
120 ngcbATTR(const char *n, int *a, int nr = 1);
121
123 ngcbATTR(const char *n, unsigned int *a, int nr = 1);
124
126 ngcbATTR(const char *n, float *a, int nr = 1);
127
129 ngcbATTR(const char *n, double *a, int nr = 1);
130
132 ngcbATTR(const char *n, long int *a, int nr = 1);
133
135 ngcbATTR(const char *n, unsigned long *a, int nr = 1);
136
138 ngcbATTR(const char *n, long long int *a, int nr = 1);
139
141 ngcbATTR(const char *n, unsigned long long int *a, int nr = 1);
142
144 virtual ~ngcbATTR();
145
147 void Pool(char *p);
148
150 int Changed();
151
153 int Update();
154
156 int Type();
157
159 int Size();
160
162 int RecordSize();
163
165 int NumRecord();
166
168 void *Addr();
169
171 int Write();
172
174 virtual int Export();
175
176protected:
177
178private:
180 void *value_;
181
183 int type_;
184
186 int size_;
187
189 int recordSize_;
190
192 int numRecord_;
193
195 void *addr_;
196
198 char *pool_;
199
201 void Init_(const char *n, void *a, int nr);
202};
203
207class ngcbDB {
208public:
211
213 ngcbDB &operator=(const ngcbDB &other);
214
216 ngcbDB(const ngcbDB &other);
217
219 ngcbDB();
220
222 explicit ngcbDB(char *p);
223
225 virtual ~ngcbDB();
226
228 void PoolInit();
229
231 size_t PoolSize();
232
234 const char *Pool();
235
237 void DelAttr();
238
240 void DelAttr(int idx);
241
243 int Add(ngcbATTR *newAttr);
244
246 void WaitState(int value);
247
249 void WaitTime(int value);
250
252 void InitDelay(int value);
253
255 int Update(int idx);
256
258 int Update();
259
261 int Export();
262
263protected:
264
265private:
267 ngcbATTR **attr_;
268
270 int numAttr_;
271
273 char *pool_;
274
276 int native_;
277
279 int waitState_;
280
282 int waitTime_;
283
285 int delayTime_;
286
288 void Init_();
289};
290
291#endif
Definition ngcbATTR.hpp:63
char name[256]
Attribute name.
Definition ngcbATTR.hpp:66
int Update()
Update attribute if changed.
Definition ngcbATTR.cpp:197
ngcbATTR(const char *n, void *a, int rs, int nr=1)
Constructor for generic types.
Definition ngcbATTR.cpp:14
int Size()
Storage size of the attribute.
Definition ngcbATTR.cpp:204
int * waitState
Pointer to wait-state counter for high latency databases.
Definition ngcbATTR.hpp:69
int delay
Initialization delay in microseconds.
Definition ngcbATTR.hpp:72
int RecordSize()
Record size of the attribute.
Definition ngcbATTR.cpp:206
virtual int Export()
Attribute export function.
Definition ngcbATTR.cpp:231
void Pool(char *p)
Set attribute pool.
Definition ngcbATTR.cpp:176
virtual ~ngcbATTR()
Destructor.
Definition ngcbATTR.cpp:174
int Write()
Write attribute.
Definition ngcbATTR.cpp:212
void * Addr()
Physical address of the attribute.
Definition ngcbATTR.cpp:210
int Type()
Type of the attribute.
Definition ngcbATTR.cpp:202
int Changed()
Check if attribute has changed.
Definition ngcbATTR.cpp:178
int NumRecord()
Number of records.
Definition ngcbATTR.cpp:208
void PoolInit()
Initialize attribute pool.
Definition ngcbDB.cpp:205
int Add(ngcbATTR *newAttr)
Add attribute.
Definition ngcbDB.cpp:235
ngcbDB & operator=(const ngcbDB &other)
Operator =.
Definition ngcbDB.cpp:14
void WaitTime(int value)
Set wait time (microseconds)
Definition ngcbDB.cpp:279
size_t PoolSize()
Size of the attribute pool.
Definition ngcbDB.cpp:210
virtual ~ngcbDB()
Destructor.
Definition ngcbDB.cpp:187
int waitState
Wait state for high latency databases.
Definition ngcbATTR.hpp:210
const char * Pool()
Return attribute pool.
Definition ngcbDB.cpp:212
ngcbDB()
Constructor.
Definition ngcbDB.cpp:149
void WaitState(int value)
Set number of states before wait.
Definition ngcbDB.cpp:273
void InitDelay(int value)
Set initialization delay (microseconds)
Definition ngcbDB.cpp:284
int Update()
Update all attributes which have changed.
Definition ngcbDB.cpp:295
void DelAttr()
Delete all attributes.
Definition ngcbDB.cpp:214
int Export()
Export all attributes.
Definition ngcbDB.cpp:314
ngcbDB(const ngcbDB &other)
Copy constructor.
Definition ngcbDB.cpp:84
char ngcb_attr_s64[64]
Definition ngcbATTR.hpp:51
char ngcb_attr_s20[20]
Definition ngcbATTR.hpp:54
char ngcb_attr_s8[8]
Definition ngcbATTR.hpp:57
char ngcb_attr_s12[12]
Definition ngcbATTR.hpp:56
char ngcb_attr_s48[48]
Definition ngcbATTR.hpp:52
char ngcb_attr_s256[256]
Definition ngcbATTR.hpp:49
char ngcb_attr_s128[128]
Definition ngcbATTR.hpp:50
char ngcb_attr_s32[32]
Definition ngcbATTR.hpp:53
char ngcb_attr_s4[4]
Definition ngcbATTR.hpp:58
char ngcb_attr_s16[16]
Definition ngcbATTR.hpp:55