source: main/trunk/greenstone2/common-src/src/lib/jdbmnaiveclass.h@ 21405

Last change on this file since 21405 was 21405, checked in by davidb, 14 years ago

Introduction of jdbm DB class that is comparable with gdbm

File size: 2.6 KB
Line 
1/**********************************************************************
2 *
3 * jdbmnaiveclass.h --
4 * Copyright (C) 1999-2010 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 JDBMNAIVECLASS_H
27#define JDBMNAIVECLASS_H
28
29// This implementation is simple but potentially inefficient (hence 'naive')
30// For each operation is runs a separate "java -cp ... " command
31// A more efficient implementation would open a connection to
32// JdbmAPI and then use a bi-directional pipe for issuing commands and
33// (in the case of Get) reading back the answer.
34//
35// While there is off-the-shelf code for a bi-directional pipe for Unix
36// (see gsdl-music) this has not yet been implemented for Windows (would need
37// to make use of Windows native calls to CreatePipe and CreateProcess)
38
39#include "gsdlconf.h"
40#include "dbclass.h"
41
42#ifdef __WIN32__
43
44#ifdef __cplusplus
45 extern "C" {
46#endif
47// Check to see if these are still needed // *****
48#include "autoconf.h"
49#include "systems.h"
50#ifdef __cplusplus
51 }
52#endif
53
54#endif
55
56
57class jdbmnaiveclass : public dbclass
58{
59public:
60 jdbmnaiveclass(const text_t& gsdlhome);
61 ~jdbmnaiveclass();
62
63 // returns true if opened
64 bool opendatabase (const text_t &filename, int mode, int num_retrys, bool need_filelock);
65
66 void closedatabase ();
67
68 void deletekey (const text_t &key);
69
70 // returns file extension string
71 text_t getfileextension ();
72
73 // returns true on success
74 bool getkeydata (const text_t& key, text_t &data);
75
76 // returns array of keys
77 text_tarray getkeys ();
78
79 // returns true on success
80 bool setkeydata (const text_t &key, const text_t &data);
81
82protected:
83 text_t openfile_;
84 text_t classpath_;
85 char* classpath_cstr_;
86 text_t gsdlhome_;
87};
88
89
90#endif
Note: See TracBrowser for help on using the repository browser.