UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
dbtc.h
1 /* dbtc.h */
2 /* $Id: dbtc.h,v 1.41 2009/03/27 09:37:00 vlad Exp $ */
3 
20 /* Encoding: ISO-8859-5 (GOST) */
21 
22 #ifndef __dbtc_h
23 
24 #define __dbtc_h
25 
26 #include <mix/General.h>
27 #include <mix/Exceptions.h>
28 #include <mix/Types.h>
29 #include <mix/units.h>
30 #include <mix/mutex.h>
31 #include <ldb/dbdefs.h>
32 #include <ldb/dbnamedefs.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif /* __cplusplus */
37 
47 typedef void* dbHandle;
48 
50 #define DB_PRECISION (0.00001)
51 
52 /* Order flags
53  * ASC -- ascent: a(i) <= a(i+1)
54  * DSC -- descent: a(i) >= a(i+1)
55  */
56 #define DB_ASC1 0
57 #define DB_DSC1 (1<<0)
58 #define DB_ASC2 0
59 #define DB_DSC2 (1<<1)
60 #define DB_ASC3 0
61 #define DB_DSC3 (1<<2)
62 #define DB_ASC (DB_ASC1|DB_ASC2|DB_ASC3)
63 #define DB_DSC (DB_DSC1|DB_DSC2|DB_DSC3)
64 
65 /* Mode of data base open */
66 #define DB_CREATE DbCreateFile
67 #define DB_WRITE DbReadWriteFile
68 #define DB_READ DbReadOnlyFile
69 #define DB_MEMORY DbMemory
72 /*************************************************************
73  * Open-close/create-delete operations
74  *************************************************************/
75 
78 dbHandle dbOpen (const char* szProject,
79  dbNameStruct* pName,
80  DbAccess mode);
81 
84 dbHandle dbOpenName (const char* szProject,
85  char* szDbFileName,
86  DbAccess mode);
87 
90 dbHandle dbOpenItem (const char* szProject,
91  dbItem* item,
92  DbAccess mode);
93 
99 dbHandle dbOpenItemEx (const char* szProject,
100  dbItem* item,
101  DbAccess mode,
102  dbNameStruct* dbmask);
103 
105 dbHandle dbOpenList (const char* szProject,
106  const char* szTableType,
107  DbAccess mode);
108 
110 dbHandle dbOpenIndex (const char* szProject,
111  const char* szTableType,
112  DbIndex lineIndex,
113  DbAccess mode);
114 
116 dbHandle dbOpenPointer (dbPointer* pdb,
117  DbAccess mode);
118 
122 void dbReopen (dbHandle dbh,
123  DbAccess mode);
124 
126 void dbClose (dbHandle dbh);
127 
129 void dbRemove (const char* szProject,
130  const dbNameStruct* pName);
131 
133 void dbRename (const char* szProject,
134  const dbNameStruct* pOldName,
135  const dbNameStruct* pNewName);
136 
138 void dbRestoreLock (dbHandle dbh);
139 
141 MutexId* dbMutex (dbHandle dbh);
142 
143 
144 /*************************************************************
145  * Operations for descriptor base
146  *************************************************************/
147 
149 char** dbTableTypeList (int* pNumber);
150 
154 Logic dbCheckTable (const char* szTableName);
155 
157 ErrCode dbRegisterTableType (const char* ttname,
158  unsigned dmns_n,
159  const DbDomainDesc* dmns);
160 
163 ErrCode dbFetchTableType (const char* ttname,
164  unsigned* dmns_n,
165  DbDomainDesc** dmns);
166 
167 /*************************************************************
168  * Infomation and protection around modification.
169  *************************************************************/
170 
172 Logic dbIsModified (dbHandle dbh);
173 
175 Logic dbIsModifiable (dbHandle dbh);
176 
179 void dbSetModified (dbHandle dbh, Logic bFlag);
180 
182 void dbSetModifiable (dbHandle dbh, Logic bFlag);
183 
184 /*************************************************************
185  * Table information operations
186  *************************************************************/
187 
190 const char* dbTableType (dbHandle dbh);
191 
193 const char* dbFileName (dbHandle dbh);
194 
196 const dbNameStruct* dbStructuredName (dbHandle dbh);
197 
199 const char* dbProject (dbHandle dbh);
200 
202 DbIndex dbLinesCount (dbHandle dbh);
203 
206 int dbColumnsCount (dbHandle dbh);
207 
212 dbNameStruct* dbNameByItem (const char* szProject,
213  dbItem* dbi, dbNameStruct* dbns);
214 
217 ErrCode dbThisTableType (dbHandle dbh,
218  unsigned* dmns_n,
219  DbDomainDesc** dmns);
220 
221 /*************************************************************
222  * Physical units support
223  *************************************************************/
224 
226 void dbSetUnit (dbHandle dbh,
227  const char* szColumnName,
228  UnitId eUnit);
229 
231 UnitId dbGetUnit (dbHandle dbh,
232  const char* szColumnName);
233 
236 CategoryId dbColumnUnitCateg (dbHandle dbh,
237  const char* szColumnName);
238 
239 /*************************************************************
240  * The whole table operations
241  *************************************************************/
242 
244 void dbCleanTable (dbHandle dbh);
245 
247 void dbFlush (dbHandle dbh);
248 
251 void dbSort1 (dbHandle dbh,
252  const char* szColumnName1,
253  int orderFlags);
254 
257 void dbSort2 (dbHandle dbh,
258  const char* szColumnName1,
259  const char* szColumnName2,
260  int orderFlags);
261 
265 void dbSort3 (dbHandle dbh,
266  const char* szColumnName1,
267  const char* szColumnName2,
268  const char* szColumnName3,
269  int orderFlags);
270 
271 /*************************************************************
272  * Per column operations
273  *************************************************************/
274 
276 void dbColumnName (dbHandle dbh,
277  int columnIndex,
278  char* szColumnName);
279 
282 AtomType dbColumnType (dbHandle dbh,
283  const char* szColumnName);
284 
287 int dbColumnDim (dbHandle dbh,
288  const char* szColumnName);
289 
293 Logic dbCheckColumn (dbHandle dbh,
294  const char* szColumnName);
295 
298 int dbColumnDefaultInt (dbHandle dbh,
299  const char* szColumnName);
300 
303 float dbColumnDefaultFloat (dbHandle dbh,
304  const char* szColumnName);
305 
307 Logic dbCheckNumericColumn (dbHandle dbh,
308  const char* szColumnName);
309 
310 /*************************************************************
311  * Per line operations
312  *************************************************************/
313 
315 void dbAddLine (dbHandle dbh);
316 
318 void dbAddLines (dbHandle dbh, DbIndex lines);
319 
322 void dbInsertLine (dbHandle dbh, DbIndex index);
323 
326 void dbInsertLines (dbHandle dbh, DbIndex index, DbIndex lines);
327 
329 void dbRemoveLine (dbHandle dbh, DbIndex index);
330 
332 void dbRemoveLines (dbHandle dbh, DbIndex startIndex,
333  DbIndex endIndex);
334 
336 void dbMergeTables (dbHandle dbhDst, dbHandle dbhSrc);
337 
339 void dbCopyTables (dbHandle dbhDst, DbIndex iWhere,
340  dbHandle dbhSrc, DbIndex iFrom, DbIndex nLines);
341 
342 /*************************************************************
343  * Get scalar per cell operations
344  *************************************************************/
345 
348 double dbGetFloat (dbHandle dbh, DbIndex lineIndex,
349  const char* szColumnName);
350 
353 int dbGetInt (dbHandle dbh, DbIndex lineIndex,
354  const char* szColumnName);
355 
358 long long dbGetInt8 (dbHandle dbh, DbIndex lineIndex,
359  const char* szColumnName);
360 
362 char dbGetChar (dbHandle dbh, DbIndex lineIndex,
363  const char* szColumnName);
364 
366 void dbGetPtr (dbHandle dbh, DbIndex lineIndex,
367  const char* szColumnName,
368  dbPointer* pPtr);
369 
371 void dbGetPointer (dbHandle dbh, DbIndex lineIndex,
372  dbPointer* pPtr);
373 
374 /*************************************************************
375  * Get vector per cell operations
376  *************************************************************/
377 
380 char* dbGetString (dbHandle dbh, DbIndex lineIndex,
381  const char* szColumnName,
382  char* sValue);
383 
387 void dbGetFloatAr (dbHandle dbh, DbIndex lineIndex,
388  const char* szColumnName,
389  float* ar);
390 
394 void dbGetDoubleAr (dbHandle dbh, DbIndex lineIndex,
395  const char* szColumnName,
396  double* ar);
397 
401 void dbGetIntAr (dbHandle dbh, DbIndex lineIndex,
402  const char* szColumnName,
403  int* ar);
404 
408 void dbGetInt8Ar (dbHandle dbh, DbIndex lineIndex,
409  const char* szColumnName,
410  long long* ar);
411 
412 /*************************************************************
413  * Read the whole column of cells
414  *************************************************************/
415 
418 void dbGetIntColumn (dbHandle dbh,
419  DbIndex lineStart,
420  DbIndex linesCnt,
421  const char* szColumnName,
422  int* ar);
423 
426 void dbGetIntArColumn (dbHandle dbh,
427  DbIndex lineStart,
428  DbIndex linesCnt,
429  const char* szColumnName,
430  int** arOfAr);
431 
434 void dbGetInt8Column (dbHandle dbh,
435  DbIndex lineStart,
436  DbIndex linesCnt,
437  const char* szColumnName,
438  long long* ar);
439 
442 void dbGetInt8ArColumn (dbHandle dbh,
443  DbIndex lineStart,
444  DbIndex linesCnt,
445  const char* szColumnName,
446  long long** arOfAr);
447 
450 void dbGetFloatColumn (dbHandle dbh,
451  DbIndex lineStart,
452  DbIndex linesCnt,
453  const char* szColumnName,
454  float* ar);
455 
458 void dbGetFloatArColumn (dbHandle dbh,
459  DbIndex lineStart,
460  DbIndex linesCnt,
461  const char* szColumnName,
462  float** arOfAr);
463 
466 void dbGetDoubleColumn (dbHandle dbh,
467  DbIndex lineStart,
468  DbIndex linesCnt,
469  const char* szColumnName,
470  double* ar);
471 
474 void dbGetDoubleArColumn (dbHandle dbh,
475  DbIndex lineStart,
476  DbIndex linesCnt,
477  const char* szColumnName,
478  double** arOfAr);
479 
481 Logic dbCheckEmptyValue (dbHandle dbh, DbIndex lineIndex,
482  const char* szColumnName);
483 
484 /*************************************************************
485  * Set scalar per cell operations
486  *************************************************************/
487 
490 void dbSetFloat (dbHandle dbh, DbIndex lineIndex,
491  const char* szColumnName, double value);
492 
495 void dbSetInt (dbHandle dbh, DbIndex lineIndex,
496  const char* szColumnName, int value);
497 
500 void dbSetInt8 (dbHandle dbh, DbIndex lineIndex,
501  const char* szColumnName, long long value);
502 
504 void dbSetChar (dbHandle dbh, DbIndex lineIndex,
505  const char* szColumnName, char value);
506 
508 void dbSetPtr (dbHandle dbh, DbIndex lineIndex,
509  const char* szColumnName,
510  const dbPointer* pPtr);
511 
513 void dbSetPointer (dbHandle dbh, DbIndex lineIndex,
514  const dbPointer* pPtr);
515 
516 /*************************************************************
517  * Set vector per cell operations
518  *************************************************************/
519 
522 void dbSetString (dbHandle dbh, DbIndex lineIndex,
523  const char* szColumnName,
524  const char* sValue);
525 
529 void dbSetFloatAr (dbHandle dbh, DbIndex lineIndex,
530  const char* szColumnName,
531  const float* ar);
532 
536 void dbSetDoubleAr (dbHandle dbh, DbIndex lineIndex,
537  const char* szColumnName,
538  const double* ar);
539 
542 void dbSetIntAr (dbHandle dbh, DbIndex lineIndex,
543  const char* szColumnName,
544  const int* ar);
545 
549 void dbSetInt8Ar (dbHandle dbh, DbIndex lineIndex,
550  const char* szColumnName,
551  const long long* ar);
552 
553 /*************************************************************
554  * Write the whole column of cells
555  *************************************************************/
556 
559 void dbSetIntColumn (dbHandle dbh,
560  DbIndex lineStart,
561  DbIndex linesCnt,
562  const char* szColumnName,
563  const int* ar);
564 
567 void dbSetIntArColumn (dbHandle dbh,
568  DbIndex lineStart,
569  DbIndex linesCnt,
570  const char* szColumnName,
571  const int** arOfAr);
572 
575 void dbSetInt8Column (dbHandle dbh,
576  DbIndex lineStart,
577  DbIndex linesCnt,
578  const char* szColumnName,
579  const long long* ar);
580 
583 void dbSetInt8ArColumn (dbHandle dbh,
584  DbIndex lineStart,
585  DbIndex linesCnt,
586  const char* szColumnName,
587  const long long** arOfAr);
588 
591 void dbSetFloatColumn (dbHandle dbh,
592  DbIndex lineStart,
593  DbIndex linesCnt,
594  const char* szColumnName,
595  const float* ar);
596 
599 void dbSetFloatArColumn (dbHandle dbh,
600  DbIndex lineStart,
601  DbIndex linesCnt,
602  const char* szColumnName,
603  const float** arOfAr);
604 
607 void dbSetDoubleColumn (dbHandle dbh,
608  DbIndex lineStart,
609  DbIndex linesCnt,
610  const char* szColumnName,
611  const double* ar);
612 
615 void dbSetDoubleArColumn (dbHandle dbh,
616  DbIndex lineStart,
617  DbIndex linesCnt,
618  const char* szColumnName,
619  const double** arOfAr);
620 
622 void dbSetEmptyValue (dbHandle dbh, DbIndex lineIndex,
623  const char* szColumnName);
624 
625 
626 #ifndef __dbtc_vars
627 
628 
630 extern TLStorage int dbStatus;
631 
633 extern volatile double dbEpsilon;
634 
635 #endif /* __dbtc_vars */
636 
637 #ifdef __cplusplus
638 };
639 #endif /* __cplusplus */
640 
641 #endif /* dbtc.h */
Definition: dbnamedefs.h:67
Definition: dbdefs.h:169
Definition: dbnamedefs.h:103
Definition: dbnamedefs.h:85