source: gsdl/trunk/lib/dbclass.h@ 15645

Last change on this file since 15645 was 15645, checked in by mdewsnip, 16 years ago

(Adding new DB support) Rearranging functions and making getkeydata() required by subclasses so they can be used with the history.db file.

File size: 2.8 KB
RevLine 
[15436]1/**********************************************************************
2 *
3 * dbclass.h --
4 * Copyright (C) 1999-2008 The New Zealand Digital Library Project
5 *
6 * A component of the Greenstone digital library software
7 * from the New Zealand Digital Library Project at the
8 * University of Waikato, New Zealand.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 *********************************************************************/
25
26#ifndef DBCLASS_H
27#define DBCLASS_H
28
29
30#include "text_t.h"
31#include "infodbclass.h"
32
33#if defined(GSDL_USE_OBJECTSPACE)
34# include <ospace\std\iostream>
35# include <ospace\std\fstream>
36#elif defined(GSDL_USE_IOS_H)
37# include <iostream.h>
38# include <fstream.h>
39#else
40# include <iostream>
41# include <fstream>
42#endif
43
44
[15557]45#define DB_READER 1
46#define DB_WRITER 2
47#define DB_WRITER_CREATE 3
48
49
[15436]50class dbclass
51{
52public:
53 dbclass() { logout = &cerr; }
[15557]54 virtual ~dbclass();
[15436]55
[15645]56 void setlogout (ostream *logout_arg) { logout = logout_arg; }
[15557]57
58 // returns true if opened
[15645]59 virtual bool opendatabase (const text_t &filename, int mode, int num_retrys, bool need_filelock) = 0;
[15557]60
[15645]61 virtual void closedatabase () = 0;
62
63 virtual void deletekey (const text_t &key) = 0;
64
[15585]65 // returns true if exists
[15645]66 virtual bool exists (const text_t& key) = 0;
[15585]67
[15557]68 // returns true on success
[15645]69 virtual bool getinfo (const text_t& key, infodbclass &info) = 0;
[15557]70
[15585]71 // returns true on success
[15645]72 virtual bool getkeydata (const text_t& key, text_t &data) = 0;
[15585]73
[15645]74 // returns array of keys
[15630]75 virtual text_tarray getkeys () = 0;
[15585]76
[15645]77 // returns true on success
78 virtual bool setinfo (const text_t &key, const infodbclass &info) = 0;
[15585]79
[15598]80 // replaces the .c, .p, .n, .l syntax (child, parent, next, previous)
81 // it expects child, parent, etc. to exist if syntax has been used
82 // so you should test before using
83 text_t translate_OID(const text_t &OID, infodbclass &info);
84
[15436]85protected:
86 ostream *logout;
[15598]87
88 void get_first_child (text_t &OID, infodbclass &info);
89 void get_last_child (text_t &OID, infodbclass &info);
90 void get_next_sibling (text_t &OID, infodbclass &info);
91 void get_previous_sibling (text_t &OID, infodbclass &info);
[15436]92};
93
94
95#endif
Note: See TracBrowser for help on using the repository browser.