Ignore:
Timestamp:
2008-05-20T10:22:16+12:00 (16 years ago)
Author:
mdewsnip
Message:

(Adding new DB support) Changed the gdbmsource classes to use dbclass instead of gdbmclass, as part of reducing the dependence on gdbm.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/src/colservr/gdbmsource.cpp

    r13780 r15584  
    3131
    3232gdbmsourceclass::gdbmsourceclass () {
    33   gdbmptr = NULL;
     33  db_ptr = NULL;
    3434  textsearchptr = NULL;
    3535  classname = "gdbmsource";
     
    3737
    3838gdbmsourceclass::~gdbmsourceclass () {
    39   if (gdbmptr != NULL) delete gdbmptr;
     39  if (db_ptr != NULL) delete db_ptr;
    4040  if (textsearchptr != NULL) delete textsearchptr;
    4141}
     
    117117    indexstem = collection;
    118118  }
    119   gdbm_filename = filename_cat(gdbmhome, "collect", collection, "index", "text", indexstem);
    120   if (littleEndian()) gdbm_filename += ".ldb";
    121   else gdbm_filename += ".bdb";
    122 
    123   if (!file_exists(gdbm_filename)) {
     119  db_filename = filename_cat(gdbmhome, "collect", collection, "index", "text", indexstem);
     120  if (littleEndian()) db_filename += ".ldb";
     121  else db_filename += ".bdb";
     122
     123  if (!file_exists(db_filename)) {
    124124    logout << text_t2ascii
    125        << "warning: gdbm database \"" //****
    126        << gdbm_filename << "\" does not exist\n\n";
    127     // return false; //****
     125       << "warning: database \"" << db_filename << "\" does not exist\n\n";
     126    // return false;
    128127  }
    129128 
     
    137136
    138137  err = noError;
    139   if (gdbmptr == NULL) {
     138  if (db_ptr == NULL) {
    140139    // most likely a configuration problem
    141140    logout << text_t2ascii
    142        << "configuration error: " << classname << " contains a null gdbmclass\n\n";
     141       << "configuration error: " << classname << " contains a null dbclass\n\n";
    143142    err = configurationError;
    144143    return true;
     
    146145
    147146  // open the database
    148   gdbmptr->setlogout(&logout);
    149   if (!gdbmptr->opendatabase (gdbm_filename, GDBM_READER, 100, false)) {
    150     // most likely a system problem (we have already checked that the
    151     // gdbm database exists)
     147  db_ptr->setlogout(&logout);
     148  if (!db_ptr->opendatabase (db_filename, DB_READER, 100, false)) {
     149    // most likely a system problem (we have already checked that the database exists)
    152150    logout << text_t2ascii
    153        << "system problem: open on gdbm database \""
    154        << gdbm_filename << "\" failed\n\n";
     151       << "system problem: open on database \"" << db_filename << "\" failed\n\n";
    155152    err = systemProblem;
    156153    return true;
     
    158155
    159156  infodbclass info;
    160   OIDout = gdbmptr->translate_OID (OIDin, info);
    161   gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
     157  OIDout = db_ptr->translate_OID (OIDin, info);
     158  db_ptr->closedatabase();  // Important that local library doesn't leave any files open
    162159  return true;
    163160}
     
    172169
    173170  err = noError;
    174   if (gdbmptr == NULL) {
     171  if (db_ptr == NULL) {
    175172    // most likely a configuration problem
    176173    logout << text_t2ascii
    177        << "configuration error: " << classname <<" contains a null gdbmclass\n\n";
     174       << "configuration error: " << classname <<" contains a null dbclass\n\n";
    178175    err = configurationError;
    179176    return true;
     
    181178
    182179  // open the database
    183   gdbmptr->setlogout(&logout);
    184   if (!gdbmptr->opendatabase (gdbm_filename, GDBM_READER, 100, false)) {
    185     // most likely a system problem (we have already checked that the
    186     // gdbm database exists)
     180  db_ptr->setlogout(&logout);
     181  if (!db_ptr->opendatabase (db_filename, DB_READER, 100, false)) {
     182    // most likely a system problem (we have already checked that the database exists)
    187183    logout << text_t2ascii
    188        << "system problem: open on gdbm database \""
    189        << gdbm_filename << "\" failed\n\n";
     184       << "system problem: open on database \"" << db_filename << "\" failed\n\n";
    190185    err = systemProblem;
    191186    return true;
     
    204199  while (this_OID != end_OID) {
    205200    infodbclass info;
    206     if (!gdbmptr->getinfo(*this_OID, info)) return false;
     201    if (!db_ptr->getinfo(*this_OID, info)) return false;
    207202
    208203    // adjust the metadata
     
    260255          parentOID = thisparent;
    261256          parentcontents.erase(parentcontents.begin(), parentcontents.end());
    262           if (gdbmptr->getinfo(parentOID, parentinfo)) {
     257          if (db_ptr->getinfo(parentOID, parentinfo)) {
    263258        text_t &parentinfocontains = parentinfo["contains"];
    264259        if (!parentinfocontains.empty())
     
    316311  }
    317312
    318   gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
     313  db_ptr->closedatabase();  // Important that local library doesn't leave any files open
    319314  return true;
    320315}
     
    327322
    328323  err = noError;
    329   if (gdbmptr == NULL) {
     324  if (db_ptr == NULL) {
    330325    // most likely a configuration problem
    331326    logout << text_t2ascii
    332        << "configuration error: " << classname << " contains a null gdbmclass\n\n";
     327       << "configuration error: " << classname << " contains a null dbclass\n\n";
    333328    err = configurationError;
    334329    return true;
     
    336331
    337332  // open the database
    338   gdbmptr->setlogout(&logout);
    339   if (!gdbmptr->opendatabase (gdbm_filename, GDBM_READER, 100, false)) {
    340     // most likely a system problem (we have already checked that the
    341     // gdbm database exists)
     333  db_ptr->setlogout(&logout);
     334  if (!db_ptr->opendatabase (db_filename, DB_READER, 100, false)) {
     335    // most likely a system problem (we have already checked that the database exists)
    342336    logout << text_t2ascii
    343        << "system problem: open on gdbm database \""
    344        << gdbm_filename << "\" failed\n\n";
     337       << "system problem: open on database \"" << db_filename << "\" failed\n\n";
    345338    err = systemProblem;
    346339    return true;
     
    351344    translate_OID (OID, tOID, err, logout);
    352345  infodbclass info;
    353   if (!gdbmptr->getinfo(tOID, info)) {
    354     gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
     346  if (!db_ptr->getinfo(tOID, info)) {
     347    db_ptr->closedatabase();  // Important that local library doesn't leave any files open
    355348    return false;
    356349  }
     
    367360  }
    368361
    369   gdbmptr->closedatabase();  // Important that local library doesn't leave any files open
     362  db_ptr->closedatabase();  // Important that local library doesn't leave any files open
    370363  return true;
    371364}
Note: See TracChangeset for help on using the changeset viewer.