a99  V32.6
allegro Windows Hauptprogramm
 Alle Klassen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
abase.hpp
gehe zur Dokumentation dieser Datei
1 // abase.hpp : Datenbank als Objekt
2 // 1995-08-26 : Hauptfunktion : Saetze einer Datenbank lesen
3 // Copyright 2011 Universitätsbibliothek Braunschweig, more see bottom
4 
5 // Klasse ABASE (c) UB Braunschweig 1995
6 // ACHTUNG: Schreibfunktionen in abasew.cpp
7 
8 // Derived from INDEX (which derives from EXET)
9 
10 #ifndef __ALLEGRO
11 #include "allegro.hpp"
12 #endif
13 
14 #ifndef __ABASE
15 #define __ABASE
16 
17 // Folgende Klassen werden gebraucht:
18 
19 #include "konfig.hpp"
20 #include "index.hpp"
21 #include "exet.hpp"
22 #include "record.hpp"
23 
24 // Konstruktor
25 class ABASE : public INDEX // d.h. INDEX ist Basisklasse
26 {
27 public:
28 
29 // Hilfsvar., die innerhalb ABASE global verfuegbar sein muessen:
30 // RECORD *Rcu; // Satzobjekt fuer Put(), definiert in index.hpp
31 
32  int cri, gri; // werden aus RECORD entnommen
33  // cri = 0, ausser bei hierarch.Untersatz, gri=Anz. Felder des Satzes
34  CHAR **ga; // Adressenarray der Felder
35  CHAR *gend; // Adresse hinter dem Satz
36  int *gi; // Array der internen Feldnummern
37 
38  int inputFi; // file# for new records
39  int writeFi; // file# for current Put()
40  int wrfl; // nr of keys written
41 
42  int Alock; // most recent lock operation status code
43  // Der zuletzt bei irgendeiner Sperr- oder Freigabeaktion registrierte Status (Fehlercode)
44  // Sollte dann sofort ausgewertet werden, bevor die naechste solche Aktion kommt
45 
46 // Hilfsvar. fuer Speicherung bei Umlagerung:
48  long oldrad; // Satzadr vor dem Speichern
49  int oldrlg; // alte Laenge
50  int oldfn; // alte Dateinr.
51 
52  int opt_N; // Option -N 0, 1, 2
53 
54  long filmax; // max length for .ALD
55 
56  long sct; // save counter: nr of saved rec's during session or job $$120116
57 
58 // ABASE::ABASE() -------------------------------------
59 // Konstruktor
60 
61 // DbDIr APIname KONFIG
62 //z.B. ABASE("C:\ALLEGRO\DEMO\","CAT", "a")
63 
64  ABASE(char *dbdir, char *dbn, KONFIG *kfg,int acc=0,char *logName=NULL,
65  int opt_n=2, long lFileMax=16000000L,
66  int inputFiNr=1, char *inxName=NULL, char *inxParam=NULL);
67 
68 // dbdir Database directory
69 // dbn database name
70 // kfg Konfig
71 // acc Accesss flag (0..3)
72 // Vorher: KONFIG kfg=new KONFIG("A");
73 
74 // Destruktor $$970129 NEU
75  virtual ~ABASE();
76 
77 
78 // ========
79 // Methoden
80 // ========
81 
82 // ABASE::AbGet() -----------------------------
83 // read a rec into a RECORD object:
84 
85 int AbGet(RECNR recn, RECORD *rec, int md=0); // %% findrec();
86 
87 // recn = 0L : re-load latest record that was in rec
88 // md = 0 : new rec, as opposed to:
89 // 1 : stack it up in record space
90 // 2 : get file# + addr only
91 // return: EOF file not good
92 // 0 rec was not properly prepared
93 // gri number of fields of this rec
94 
95 
96 // ABASE::AwRecAdr() --------------------------------------
97 // find record address
98 // return file# , (>0 <256), offset is returned in of
99 // 0 : recn is not in use or other trouble
100 // -1 : trouble with .TBL file
101 
102 int AbRecChk(RECNR recn); // check rec#
103 // return: 0 : recn too large or no ALD file
104 // 1 : OK
105 // -2 : recn <0
106 // -1 : not in use (unbesetzt)
107 
108 int AbRecAdr(RECNR recn, long &of);
109 
110 // Example: int filNr; long offSet;
111 // filNr = dataBase->RecAdr(1L,offSet);
112 // if(filNr < 1) { ... error handling ... }
113 
114 // ---------------------------------------------------------
115 
116 
117 int AbExpV14(RECORD*, EXET *, int mn=0, char *labl=0, RECORD *Bac=0);
118  // means: export the RECORD using the param set EXET
119  // with possible V14 replacements
120 
121 
122 // Schluessel eines Satzes ermitteln
123  int AbKeys(RECORD *Rcu, int store);
124  // return # of keys or -1
125 
126 // Indexdatei oeffnen und schliessen
127  void Opnix(); // Neu $$071029 wg. FLEX ixadd/ixdel
128  void Clsix();
129 
130  int AbIsLocked(RECORD *R); // is this record locked?
131  // return: 0: file error, 1:no (free), 8:yes, 9:deleted
132 
133  RECNR Nxt(RECORD *); // naechsten verkn. Satz, per PrimSchl
134  RECNR Prv(RECORD *); // vorigen; return: Satznummer
135 
136  int PVal(FLD *); // PV-Routinen bearbeiten
137  // %% ps=0; pghf(1);
138 
139 // Nachladefunktionen
140  int ix_load(RECORD *, CHAR *, int fct, int ui4=-2);
141  // called from EXET.CPP : manip command |im
142  int ix_stack(RECORD *, int); // aufstapeln
143 
144  void ix_reset(void); // reset index pointer to the position where it was
145 
146  // %% npresto3.c
147 
148  int logflg; // 0:logging disabled
149  int dbTb; // handle of .TBL file
150 
151  char dbLog[PATH_SIZE]; // log file name
152  char dbFn[PATH_SIZE]; // data file name (z.B. c:\allegro\demo2\cat_
153  char *dbFNum; // pointer to the number part of name (after _)
154 
155 // ========
156 private:
157 
158  int alth; // actual length of current rec after editing
159 
160  FILE *fwr; // file for .ALD
161  FILE *logfile; // file for .LOG
162 
163  FILE *Openr(int fnr); // open file_fnr.ALD for reading
164 
165  void Filename(char *,char *); // make these names
166 
167 
168 #include "abasew.hpp" // Erweiterungen f. Schreibzugriff
169 
170 };
171 
172 
173 #ifdef UNIX // File-Locking-Definitionen
174 
175 //---- Einrichten oder Freigeben einer Dateisperre -------------------------
176 extern int sperre_einaus(int fd, int kdo, int sperr_typ,off_t offset, int wie, off_t laenge);
177 
178 
179 //------------ Einrichten einer Dateisperre ----------------------------
180 #define lock(fd,offset,laenge) sperre_einaus(fd, F_SETLK, F_WRLCK, offset, SEEK_CUR, laenge)
181 
182 
183 //------------ Aufheben einer Dateisperre ------------------------------
184 #define unlock(fd,offset,laenge) sperre_einaus(fd, F_SETLK, F_UNLCK, offset,SEEK_CUR, laenge)
185 
186 #endif // zu #ifdef UNIX
187 #endif // zu #ifndef ABASE
188 
189 /*
190  Copyright 2011 Universitätsbibliothek Braunschweig
191 
192  Licensed under the Apache License, Version 2.0 (the "License");
193  you may not use this file except in compliance with the License.
194  You may obtain a copy of the License at
195 
196  http://www.apache.org/licenses/LICENSE-2.0
197 
198  Unless required by applicable law or agreed to in writing, software
199  distributed under the License is distributed on an "AS IS" BASIS,
200  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201  See the License for the specific language governing permissions and
202  limitations under the License.
203 */
204