/********************************************************************** * * dbclass.h -- * Copyright (C) 1999-2008 The New Zealand Digital Library Project * * A component of the Greenstone digital library software * from the New Zealand Digital Library Project at the * University of Waikato, New Zealand. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *********************************************************************/ #ifndef DBCLASS_H #define DBCLASS_H #include "text_t.h" #include "infodbclass.h" #if defined(GSDL_USE_OBJECTSPACE) # include # include #elif defined(GSDL_USE_IOS_H) # include # include #else # include # include #endif #define DB_READER 1 #define DB_WRITER 2 #define DB_WRITER_CREATE 3 class dbclass { public: dbclass() { logout = &cerr; } virtual ~dbclass(); void setlogout(ostream *logout_arg) { logout = logout_arg; } // returns true if opened virtual bool opendatabase(const text_t &filename, int mode, int num_retrys, bool need_filelock) = 0; virtual void closedatabase() = 0; // returns true if exists virtual bool exists(const text_t& key) = 0; // returns true on success virtual bool getinfo(const text_t& key, infodbclass &info) = 0; // returns true on success virtual bool setinfo(const text_t &key, const infodbclass &info) = 0; // replaces the .c, .p, .n, .l syntax (child, parent, next, previous) // it expects child, parent, etc. to exist if syntax has been used // so you should test before using virtual text_t translate_OID(const text_t &OID, infodbclass &info) = 0; // getfirstkey and getnextkey are used for traversing the database // no insertions or deletions should be carried out while traversing // the database. when there are no keys left to visit in the database // an empty string is returned. virtual text_t getfirstkey() = 0; virtual text_t getnextkey(const text_t &key) = 0; virtual void deletekey(const text_t &key) = 0; protected: ostream *logout; }; #endif