1 /*************************************************************************************************
2  * C++ API of Villa, the advanced API of QDBM
3  *                                                      Copyright (C) 2000-2006 Mikio Hirabayashi
4  * This file is part of QDBM, Quick Database Manager.
5  * QDBM is free software; you can redistribute it and/or modify it under the terms of the GNU
6  * Lesser General Public License as published by the Free Software Foundation; either version
7  * 2.1 of the License or any later version.  QDBM is distributed in the hope that it will be
8  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
10  * details.
11  * You should have received a copy of the GNU Lesser General Public License along with QDBM; if
12  * not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
13  * 02111-1307 USA.
14  *************************************************************************************************/
15 
16 
17 #ifndef _XVILLA_H                        /* duplication check */
18 #define _XVILLA_H
19 
20 
21 #include <xqdbm.h>
22 #include <xadbm.h>
23 
24 extern "C" {
25 #include <depot.h>
26 #include <cabin.h>
27 #include <villa.h>
28 #include <stdlib.h>
29 #include <time.h>
30 }
31 
32 
33 
34 /**
35  * Error container for Villa.
36  */
37 class qdbm::Villa_error : public virtual DBM_error {
38   //----------------------------------------------------------------
39   // public member functions
40   //----------------------------------------------------------------
41 public:
42   /**
43    * Create an instance.
44    */
45   Villa_error() throw();
46   /**
47    * Create an instance.
48    * @param ecode the error code.
49    */
50   Villa_error(int ecode) throw();
51   /**
52    * Copy constructor.
53    * @param ve a source instance.
54    */
55   Villa_error(const Villa_error& ve) throw();
56   /**
57    * Release resources of the instance.
58    */
59   virtual ~Villa_error() throw();
60   /**
61    * Assignment operator.
62    * @param ve a source instance.
63    * @return reference to itself.
64    */
65   Villa_error& operator =(const Villa_error& ve) throw();
66   /**
67    * Assignment operator.
68    * @param ecode the error code.
69    * @return reference to itself.
70    */
71   Villa_error& operator =(int ecode) throw();
72   /**
73    * Equality operator.
74    * @param ve a comparing instance.
75    * @return true if both equal, else, false.
76    */
77   virtual bool operator ==(const Villa_error& ve) const throw();
78   /**
79    * Inequality operator.
80    * @param ve a comparing instance.
81    * @return true if both do not equal, else, false.
82    */
83   virtual bool operator !=(const Villa_error& ve) const throw();
84   /**
85    * Equality operator.
86    * @param ecode a comparing error code.
87    * @return true if both equal, else, false.
88    */
89   virtual bool operator ==(int ecode) const throw();
90   /**
91    * Inequality operator.
92    * @param ecode a comparing error code.
93    * @return true if both do not equal, else, false.
94    */
95   virtual bool operator !=(int ecode) const throw();
96   /**
97    * Cast operator into pointer to char.
98    * @return the pointer to the string.
99    */
100   virtual operator const char*() const throw();
101   /**
102    * Get the error code.
103    * @return the error code.
104    */
105   virtual int code() const throw();
106   /**
107    * Get the error message.
108    * @return the pointer to the string.
109    */
110   virtual const char* message() const throw();
111   //----------------------------------------------------------------
112   // private member variables
113   //----------------------------------------------------------------
114 private:
115   /** The error code. */
116   int ecode;
117 };
118 
119 
120 
121 /**
122  * C++ API of Villa, the basic API of QDBM.
123  */
124 class qdbm::Villa : public virtual ADBM {
125   //----------------------------------------------------------------
126   // public static member constants
127   //----------------------------------------------------------------
128 public:
129   static const int ENOERR;            ///< error code: no error
130   static const int EFATAL;            ///< error code: with fatal error
131   static const int EMODE;             ///< error code: invalid mode
132   static const int EBROKEN;           ///< error code: broken database file
133   static const int EKEEP;             ///< error code: existing record
134   static const int ENOITEM;           ///< error code: no item found
135   static const int EALLOC;            ///< error code: memory allocation error
136   static const int EMAP;              ///< error code: memory mapping error
137   static const int EOPEN;             ///< error code: open error
138   static const int ECLOSE;            ///< error code: close error
139   static const int ETRUNC;            ///< error code: trunc error
140   static const int ESYNC;             ///< error code: sync error
141   static const int ESTAT;             ///< error code: stat error
142   static const int ESEEK;             ///< error code: seek error
143   static const int EREAD;             ///< error code: read error
144   static const int EWRITE;            ///< error code: write error
145   static const int ELOCK;             ///< error code: lock error
146   static const int EUNLINK;           ///< error code: unlink error
147   static const int EMKDIR;            ///< error code: mkdir error
148   static const int ERMDIR;            ///< error code: rmdir error
149   static const int EMISC;             ///< error code: miscellaneous error
150   static const int OREADER;           ///< open mode: open as a reader
151   static const int OWRITER;           ///< open mode: open as a writer
152   static const int OCREAT;            ///< open mode: writer creating
153   static const int OTRUNC;            ///< open mode: writer truncating
154   static const int ONOLCK;            ///< open mode: open without locking
155   static const int OLCKNB;            ///< open mode: lock without blocking
156   static const int OZCOMP;            ///< open mode: compress leaves with ZLIB
157   static const int OYCOMP;            ///< open mode: compress leaves with LZO
158   static const int OXCOMP;            ///< open mode: compress leaves with BZIP2
159   static const int DOVER;             ///< write mode: overwrite the existing value
160   static const int DKEEP;             ///< write mode: keep the existing value
161   static const int DCAT;              ///< write mode: concatenate values
162   static const int DDUP;              ///< write mode: allow duplication of keys
163   static const int DDUPR;             ///< write mode: allow duplication with reverse order
164   static const int JFORWARD;          ///< jump mode: step forward
165   static const int JBACKWARD;         ///< jump mode: step backward
166   static const int CPCURRENT;         ///< insertion mode: overwrite the current record
167   static const int CPBEFORE;          ///< insertion mode: insert before the current record
168   static const int CPAFTER;           ///< insertion mode: insert after the current record
169   //----------------------------------------------------------------
170   // public static member functions
171   //----------------------------------------------------------------
172 public:
173   /**
174    * Get the version information.
175    * @return the string of the version information.
176    */
177   static const char* version() throw();
178   /**
179    * Remove a database directory.
180    * @param name the name of a database directory.
181    * @throw Villa_error if an error occurs.
182    */
183   static void remove(const char* name) throw(Villa_error);
184   /**
185    * Compare keys of two records by lexical order.
186    * @param aptr the pointer to the region of one key.
187    * @param asiz the size of the region of one key.
188    * @param bptr the pointer to the region of the other key.
189    * @param bsiz the size of the region of the other key.
190    * @return positive if the former is big, negative if the latter is big, 0 if both are
191    * equivalent.
192    */
193   static int cmplex(const char *aptr, int asiz, const char *bptr, int bsiz) throw();
194   /**
195    * Compare keys of two records as integers.
196    * @param aptr the pointer to the region of one key.
197    * @param asiz the size of the region of one key.
198    * @param bptr the pointer to the region of the other key.
199    * @param bsiz the size of the region of the other key.
200    * @return positive if the former is big, negative if the latter is big, 0 if both are
201    * equivalent.
202    */
203   static int cmpint(const char *aptr, int asiz, const char *bptr, int bsiz) throw();
204   /**
205    * Compare keys of two records as numbers of big endian.
206    * @param aptr the pointer to the region of one key.
207    * @param asiz the size of the region of one key.
208    * @param bptr the pointer to the region of the other key.
209    * @param bsiz the size of the region of the other key.
210    * @return positive if the former is big, negative if the latter is big, 0 if both are
211    * equivalent.
212    */
213   static int cmpnum(const char *aptr, int asiz, const char *bptr, int bsiz) throw();
214   /**
215    * Compare keys of two records as decimal strings.
216    * @param aptr the pointer to the region of one key.
217    * @param asiz the size of the region of one key.
218    * @param bptr the pointer to the region of the other key.
219    * @param bsiz the size of the region of the other key.
220    * @return positive if the former is big, negative if the latter is big, 0 if both are
221    * equivalent.
222    */
223   static int cmpdec(const char *aptr, int asiz, const char *bptr, int bsiz) throw();
224   //----------------------------------------------------------------
225   // public member functions
226   //----------------------------------------------------------------
227 public:
228   /**
229    * Get the database handle.
230    * @param name the name of a database file.
231    * @param omode the connection mode: `Villa::OWRITER' as a writer, `Villa::OREADER' as
232    * a reader.  If the mode is `Villa::OWRITER', the following may be added by bitwise or:
233    * `Villa::OCREAT', which means it creates a new database if not exist, `Villa::OTRUNC',
234    * which means it creates a new database regardless if one exists, `Villa::OZCOMP', which means
235    * leaves in the database are compressed with ZLIB, `Villa::OYCOMP', which means leaves in the
236    * database are compressed with LZO, `Villa::OXCOMP', which means leaves in the database are
237    * compressed with BZIP2.  Both of `Villa::OREADER' and `Villa::OWRITER' can be added to by
238    * bitwise or: `Villa::ONOLCK', which means it opens a database file without file locking, or
239    * `Villa::OLCKNB', which means locking is performed without blocking.
240    * @param cmp the comparing function: `Villa::cmplex' comparing keys in lexical order,
241    * `Villa::cmpint' comparing keys as objects of `int' in native byte order, `Villa::cmpnum'
242    * comparing keys as numbers of big endian, `Villa::cmpdec' comparing keys as decimal strings.
243    * Any function compatible with them can be assigned to the comparing function.  The comparing
244    * function should be kept same in the life of a database.
245    * @throw Villa_error if an error occurs.
246    * @note While connecting as a writer, an exclusive lock is invoked to the database file.
247    * While connecting as a reader, a shared lock is invoked to the database file.  The thread
248    * blocks until the lock is achieved.  `Villa::OZCOMP', `Villa::OYCOMP', and `Villa::OXCOMP'
249    * are available only if QDBM was built each with ZLIB, LZO, and BZIP2 enabled.  If
250    * `Villa::ONOLCK' is used, the application is responsible for exclusion control.
251    */
252   Villa(const char* name, int omode = Villa::OREADER, VLCFUNC cmp = Villa::cmplex)
253     throw(Villa_error);
254   /**
255    * Release the resources.
256    * @note If the database handle is not closed yet, it is closed.
257    */
258   virtual ~Villa() throw();
259   /**
260    * Close the database handle.
261    * @throw Villa_error if an error occurs.
262    * @note Updating a database is assured to be written when the handle is closed.  If a writer
263    * opens a database but does not close it appropriately, the database will be broken.  If the
264    * transaction is activated and not committed, it is aborted.
265    */
266   virtual void close() throw(Villa_error);
267   /**
268    * Store a record.
269    * @param kbuf the pointer to the region of a key.
270    * @param ksiz the size of the region of the key.  If it is negative, the size is assigned
271    * with `std::strlen(kbuf)'.
272    * @param vbuf the pointer to the region of a value.
273    * @param vsiz the size of the region of the value.  If it is negative, the size is assigned
274    * with `std::strlen(vbuf)'.
275    * @param dmode behavior when the key overlaps, by the following values: `Villa::DOVER',
276    * which means the specified value overwrites the existing one, `Villa::DKEEP', which means
277    * the existing value is kept, `Villa::DCAT', which means the specified value is concatenated
278    * at the end of the existing value, `Villa::DDUP', which means duplication of keys is allowed
279    * and the specified value is added as the last one, `Villa::DDUPR', which means duplication of
280    * keys is allowed and the specified value is added as the first one.
281    * @return always true.  However, if the silent flag is true and replace is cancelled, false is
282    * returned instead of exception.
283    * @throw Villa_error if an error occurs or replace is cancelled.
284    * @note The cursor becomes unavailable due to updating database.
285    */
286   virtual bool put(const char* kbuf, int ksiz, const char* vbuf, int vsiz,
287                    int dmode = Villa::DOVER) throw(Villa_error);
288   /**
289    * Delete a record.
290    * @param kbuf the pointer to the region of a key.
291    * @param ksiz the size of the region of the key.  If it is negative, the size is assigned
292    * with `std::strlen(kbuf)'.
293    * @return always true.  However, if the silent flag is true and no record corresponds, false
294    * is returned instead of exception.
295    * @throw Villa_error if an error occurs or no record corresponds.
296    * @note When the key of duplicated records is specified, the first record of the same key
297    * is deleted.  The cursor becomes unavailable due to updating database.
298    */
299   virtual bool out(const char* kbuf, int ksiz) throw(Villa_error);
300   /**
301    * Retrieve a record.
302    * @param kbuf the pointer to the region of a key.
303    * @param ksiz the size of the region of the key.  If it is negative, the size is assigned
304    * with `std::strlen(kbuf)'.
305    * @param sp the pointer to a variable to which the size of the region of the return value
306    * is assigned.  If it is 0, it is not used.
307    * @return the pointer to the region of the value of the corresponding record.  If the silent
308    * flag is true and no record corresponds, 0 is returned instead of exception.
309    * @throw Villa_error if an error occurs or no record corresponds.
310    * @note When the key of duplicated records is specified, the value of the first record of
311    * the same key is selected.  Because an additional zero code is appended at the end of the
312    * region of the return value, the return value can be treated as a character string.
313    * Because the region of the return value is allocated with the `std::malloc' call, it
314    * should be released with the `std::free' call if it is no longer in use.
315    */
316   virtual char* get(const char* kbuf, int ksiz, int* sp = 0) throw(Villa_error);
317   /**
318    * Get the size of the value of a record.
319    * @param kbuf the pointer to the region of a key.
320    * @param ksiz the size of the region of the key.  If it is negative, the size is assigned
321    * with `std::strlen(kbuf)'.
322    * @return the size of the value of the corresponding record.  If the silent flag is true and
323    * no record corresponds, -1 is returned instead of exception.  If multiple records correspond,
324    * the size of the first is returned.
325    * @throw Villa_error if an error occurs or no record corresponds.
326    */
327   virtual int vsiz(const char* kbuf, int ksiz) throw(Villa_error);
328   /**
329    * Get the number of records corresponding a key.
330    * @param kbuf the pointer to the region of a key.
331    * @param ksiz the size of the region of the key.  If it is negative, the size is assigned
332    * with `std::strlen(kbuf)'.
333    * @return the number of corresponding records.  If no record corresponds, 0 is returned.
334    * @throw Villa_error if an error occurs.
335    */
336   virtual int vnum(const char* kbuf, int ksiz) throw(Villa_error);
337   /**
338    * Move the cursor to the first record.
339    * @return always true.  However, if the silent flag is true and no record corresponds, false
340    * is returned instead of exception.
341    * @throw Villa_error if an error occurs or there is no record in the database.
342    */
343   virtual bool curfirst() throw(Villa_error);
344   /**
345    * Move the cursor to the last record.
346    * @return always true.  However, if the silent flag is true and no record corresponds, false
347    * is returned instead of exception.
348    * @throw Villa_error if an error occurs or there is no record in the database.
349    */
350   virtual bool curlast() throw(Villa_error);
351   /**
352    * Move the cursor to the previous record.
353    * @return always true.  However, if the silent flag is true and no record corresponds, false
354    * is returned instead of exception.
355    * @throw Villa_error if an error occurs or there is no previous record.
356    */
357   virtual bool curprev() throw(Villa_error);
358   /**
359    * Move the cursor to the next record.
360    * @return always true.  However, if the silent flag is true and no record corresponds, false
361    * is returned instead of exception.
362    * @throw Villa_error if an error occurs or there is no next record.
363    */
364   virtual bool curnext() throw(Villa_error);
365   /**
366    * Move the cursor to a position around a record.
367    * @param kbuf the pointer to the region of a key.
368    * @param ksiz the size of the region of the key.  If it is negative, the size is assigned
369    * with `std::strlen(kbuf)'.
370    * @param jmode detail adjustment: `Villa::JFORWARD', which means that the cursor is set to
371    * the first record of the same key and that the cursor is set to the next substitute if
372    * completely matching record does not exist, `Villa::JBACKWARD', which means that the cursor
373    * is set to the last record of the same key and that the cursor is set to the previous
374    * substitute if completely matching record does not exist.
375    * @return always true.  However, if the silent flag is true and no record corresponds, false
376    * is returned instead of exception.
377    * @throw Villa_error if an error occurs or there is no record corresponding the condition.
378    */
379   virtual bool curjump(const char* kbuf, int ksiz, int jmode = Villa::JFORWARD)
380     throw(Villa_error);
381   /**
382    * Get the key of the record where the cursor is.
383    * @param sp the pointer to a variable to which the size of the region of the return value
384    * is assigned.  If it is 0, it is not used.
385    * @return the pointer to the region of the key of the corresponding record.  If the silent
386    * flag is true and no record corresponds, 0 is returned instead of exception.
387    * @throw Villa_error if an error occurs or no record corresponds to the cursor.
388    * @note Because an additional zero code is appended at the end of the region of the return
389    * value, the return value can be treated as a character string.  Because the region of the
390    * return value is allocated with the `std::malloc' call, it should be released with the
391    * `std::free' call if it is no longer in use.
392    */
393   virtual char* curkey(int* sp = 0) throw(Villa_error);
394   /**
395    * Get the value of the record where the cursor is.
396    * @param sp the pointer to a variable to which the size of the region of the return value
397    * is assigned.  If it is 0, it is not used.
398    * @return the pointer to the region of the value of the corresponding record.  If the silent
399    * flag is true and no record corresponds, 0 is returned instead of exception.
400    * @throw Villa_error if an error occurs or no record corresponds to the cursor.
401    * @note Because an additional zero code is appended at the end of the region of the return
402    * value, the return value can be treated as a character string.  Because the region of the
403    * return value is allocated with the `std::malloc' call, it should be released with the
404    * `std::free' call if it is no longer in use.
405    */
406   virtual char* curval(int* sp = 0) throw(Villa_error);
407   /**
408    * Insert a record around the cursor.
409    * @param vbuf the pointer to the region of a value.
410    * @param vsiz the size of the region of the value.  If it is negative, the size is assigned
411    * with `std::strlen(vbuf)'.
412    * @param cpmode detail adjustment: `Villa::CPCURRENT', which means that the value of the
413    * current record is overwritten, `Villa::CPBEFORE', which means that a new record is inserted
414    * before the current record, `Villa::CPAFTER', which means that a new record is inserted after
415    * the current record.
416    * @return always true.  However, if the silent flag is true and no record corresponds to the
417    * cursor, false is returned instead of exception.
418    * @throw Villa_error if an error occurs or no record corresponds to the cursor.
419    * @note After insertion, the cursor is moved to the inserted record.
420    */
421   virtual bool curput(const char* vbuf, int vsiz, int cpmode = Villa::CPCURRENT)
422     throw(Villa_error);
423   /**
424    * Delete the record where the cursor is.
425    * @return always true.  However, if the silent flag is true and no record corresponds to the
426    * cursor, false is returned instead of exception.
427    * @throw Villa_error if an error occurs or no record corresponds to the cursor.
428    * @note After deletion, the cursor is moved to the next record if possible.
429    */
430   virtual bool curout() throw(Villa_error);
431   /**
432    * Set the tuning parameters for performance.
433    * @param lrecmax the max number of records in a leaf node of B+ tree.  If it is not more
434    * than 0, the default value is specified.
435    * @param nidxmax the max number of indexes in a non-leaf node of B+ tree.  If it is not more
436    * than 0, the default value is specified.
437    * @param lcnum the max number of caching leaf nodes.  If it is not more than 0, the default
438    * value is specified.
439    * @param ncnum the max number of caching non-leaf nodes.  If it is not more than 0, the
440    * default value is specified.
441    * @throw Villa_error if an error occurs.
442    * @note The default setting is equivalent to `settuning(49, 192, 1024, 512)'.  Because tuning
443    * paremeters are not saved in a database, you should specify them every opening a database.
444    */
445   virtual void settuning(int lrecmax, int nidxmax, int lcnum, int ncnum) throw(Villa_error);
446   /**
447    * Synchronize updating contents with the file and the device.
448    * @throw Villa_error if an error occurs.
449    * @note This function is useful when another process uses the connected database file.  This
450    * function shuold not be used while the transaction is activated.
451    */
452   virtual void sync() throw(Villa_error);
453   /**
454    * Optimize a database.
455    * @throw Villa_error if an error occurs.
456    * @note In an alternating succession of deleting and storing with overwrite or concatenate,
457    * dispensable regions accumulate.  This function is useful to do away with them.  This
458    * function shuold not be used while the transaction is activated.
459    */
460   virtual void optimize() throw(Villa_error);
461   /**
462    * Get the name of the database.
463    * @return the pointer to the region of the name of the database.
464    * @throw Villa_error if an error occurs.
465    * @note Because the region of the return value is allocated with the `std::malloc' call,
466    * it should be released with the `std::free' call if it is no longer in use.
467    */
468   virtual char* name() throw(Villa_error);
469   /**
470    * Get the size of the database file.
471    * @return the size of the database file.
472    * @throw Villa_error if an error occurs.
473    * @note Because of the I/O buffer, the return value may be less than the real size.
474    */
475   virtual int fsiz() throw(Villa_error);
476   /**
477    * Get the number of the leaf nodes of B+ tree.
478    * @return the number of the leaf nodes.
479    * @throw Villa_error if an error occurs.
480    */
481   virtual int lnum() throw(Villa_error);
482   /**
483    * Get the number of the non-leaf nodes of B+ tree.
484    * @return the number of the non-leaf nodes.
485    * @throw Villa_error if an error occurs.
486    */
487   virtual int nnum() throw(Villa_error);
488   /**
489    * Get the number of the records stored in a database.
490    * @return the number of the records stored in the database.
491    * @throw Villa_error if an error occurs.
492    */
493   virtual int rnum() throw(Villa_error);
494   /**
495    * Check whether the database handle is a writer or not.
496    * @return true if the handle is a writer, false if not.
497    * @throw Villa_error if an error occurs.
498    */
499   virtual bool writable() throw(Villa_error);
500   /**
501    * Check whether the database has a fatal error or not.
502    * @return true if the database has a fatal error, false if not.
503    * @throw Villa_error if an error occurs.
504    */
505   virtual bool fatalerror() throw(Villa_error);
506   /**
507    * Get the inode number of the database file.
508    * @return the inode number of the database file.
509    * @throw Villa_error if an error occurs.
510    */
511   virtual int inode() throw(Villa_error);
512   /**
513    * Get the last modified time of the database.
514    * @return the last modified time the database.
515    * @throw Villa_error if an error occurs.
516    */
517   virtual time_t mtime() throw(Villa_error);
518   /**
519    * Begin the transaction.
520    * @throw Villa_error if an error occurs.
521    * @note If a thread is already in the transaction, the other threads block until the prius
522    * is out of the transaction.  Only one transaction can be activated with a database handle
523    * at the same time.
524    */
525   virtual void tranbegin() throw(Villa_error);
526   /**
527    * Commit the transaction.
528    * @throw Villa_error if an error occurs.
529    * @note Updating a database in the transaction is fixed when it is committed successfully.
530    * Any other thread except for the one which began the transaction should not call this
531    * function.
532    */
533   virtual void trancommit() throw(Villa_error);
534   /**
535    * Abort the transaction.
536    * @throw Villa_error if an error occurs.
537    * @note Updating a database in the transaction is discarded when it is aborted.  The state
538    * of the database is rollbacked to before transaction.  Any other thread except for the one
539    * which began the transaction should not call this function.
540    */
541   virtual void tranabort() throw(Villa_error);
542   /**
543    * Store a record.
544    * @param key reference to a key object.
545    * @param val reference to a value object.
546    * @param replace whether the existing value is to be overwritten or not.
547    * @throw Villa_error if an error occurs or replace is cancelled.
548    */
549   virtual void storerec(const Datum& key, const Datum& val, bool replace = true)
550     throw(Villa_error);
551   /**
552    * Delete a record.
553    * @param key reference to a key object.
554    * @throw Villa_error if an error occurs or no record corresponds.
555    */
556   virtual void deleterec(const Datum& key) throw(Villa_error);
557   /**
558    * Fetch a record.
559    * @param key reference to a key object.
560    * @return a temporary instance of the value of the corresponding record.
561    * @throw Villa_error if an error occurs or no record corresponds.
562    */
563   virtual Datum fetchrec(const Datum& key) throw(Villa_error);
564   /**
565    * Get the first key.
566    * @return a temporary instance of the key of the first record.
567    * @throw Villa_error if an error occurs or no record corresponds.
568    */
569   virtual Datum firstkey() throw(Villa_error);
570   /**
571    * Get the next key.
572    * @return a temporary instance of the key of the next record.
573    * @throw Villa_error if an error occurs or no record corresponds.
574    */
575   virtual Datum nextkey() throw(Villa_error);
576   /**
577    * Check whether a fatal error occured or not.
578    * @return true if the database has a fatal error, false if not.
579    * @throw Villa_error if an error occurs.
580    */
581   virtual bool error() throw(Villa_error);
582   //----------------------------------------------------------------
583   // public member variables
584   //----------------------------------------------------------------
585 public:
586   bool silent;                        ///< whether to repress frequent exceptions
587   //----------------------------------------------------------------
588   // private member variables
589   //----------------------------------------------------------------
590 private:
591   VILLA* villa;                       ///< internal database handle
592   pthread_mutex_t mymutex;            ///< internal mutex
593   pthread_mutex_t tranmutex;          ///< mutex for the transaction
594   //----------------------------------------------------------------
595   // private member functions
596   //----------------------------------------------------------------
597 private:
598   /** copy constructor: This should not be used. */
599   Villa(const Villa& villa) throw(Villa_error);
600   /** assignment operator: This should not be used. */
601   Villa& operator =(const Villa& villa) throw(Villa_error);
602   /** lock the database. */
603   bool lock();
604   /** unlock the database. */
605   void unlock();
606 };
607 
608 
609 
610 #endif                                   /* duplication check */
611 
612 
613 /* END OF FILE */
614