Logo Search packages:      
Sourcecode: qdbm version File versions  Download package

Curia::Curia ( const char *  name,
int  omode = Curia::OREADER,
int  bnum = -1,
int  dnum = -1 
) throw (Curia_error)

Get the database handle.

Parameters:
name the name of a database directory.
omode the connection mode: `CuriaOWRITER' as a writer, `CuriaOREADER' as a reader. If the mode is `CuriaOWRITER', the following may be added by bitwise or: `CuriaOCREAT', which means it creates a new database if not exist, `CuriaOTRUNC', which means it creates a new database regardless if one exists. Both of `CuriaOREADER' and `CuriaOWRITER' can be added to by bitwise or: `CuriaONOLCK', which means it opens a database directory without file locking, or `CuriaOLCKNB', which means locking is performed without blocking. `CuriaOCREAT' can be added to by bitwise or: `CuriaOSPARSE', which means it creates database files as sparse files.
bnum the number of elements of each bucket array. If it is not more than 0, the default value is specified. The size of each bucket array is determined on creating, and can not be changed except for by optimization of the database. Suggested size of each bucket array is about from 0.5 to 4 times of the number of all records to store.
dnum the number of division of the database. If it is not more than 0, the default value is specified. The number of division can not be changed from the initial value. The max number of division is 512.
Note:
While connecting as a writer, an exclusive lock is invoked to the database directory. While connecting as a reader, a shared lock is invoked to the database directory. The thread blocks until the lock is achieved. If `CuriaONOLCK' is used, the application is responsible for exclusion control.

Definition at line 163 of file xcuria.cc.

References bnum(), curia, qdbm::mutex, and name().

  : ADBM(){
  if(pthread_mutex_lock(&mutex) != 0) throw Curia_error();
  if(!(curia = cropen(name, omode, bnum, dnum))){
    pthread_mutex_unlock(&mutex);
    throw Curia_error(dpecode);
  }
  pthread_mutex_unlock(&mutex);
}


Generated by  Doxygen 1.6.0   Back to index