[21405] | 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 | class jdbmnaiveclass : public dbclass
|
---|
| 43 | {
|
---|
| 44 | public:
|
---|
| 45 | jdbmnaiveclass(const text_t& gsdlhome);
|
---|
| 46 | ~jdbmnaiveclass();
|
---|
| 47 |
|
---|
| 48 | // returns true if opened
|
---|
| 49 | bool opendatabase (const text_t &filename, int mode, int num_retrys, bool need_filelock);
|
---|
| 50 |
|
---|
| 51 | void closedatabase ();
|
---|
| 52 |
|
---|
| 53 | void deletekey (const text_t &key);
|
---|
| 54 |
|
---|
| 55 | // returns file extension string
|
---|
| 56 | text_t getfileextension ();
|
---|
| 57 |
|
---|
| 58 | // returns true on success
|
---|
| 59 | bool getkeydata (const text_t& key, text_t &data);
|
---|
| 60 |
|
---|
| 61 | // returns array of keys
|
---|
| 62 | text_tarray getkeys ();
|
---|
| 63 |
|
---|
| 64 | // returns true on success
|
---|
| 65 | bool setkeydata (const text_t &key, const text_t &data);
|
---|
| 66 |
|
---|
| 67 | protected:
|
---|
| 68 | text_t openfile_;
|
---|
| 69 | text_t classpath_;
|
---|
| 70 | char* classpath_cstr_;
|
---|
| 71 | text_t gsdlhome_;
|
---|
| 72 | };
|
---|
| 73 |
|
---|
| 74 |
|
---|
| 75 | #endif
|
---|