[6127] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * IsisDb.h
|
---|
| 4 | * Copyright (C) 2003 UNESCO
|
---|
| 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 | ////////////////////////////////////////////////////////////
|
---|
| 27 | // Isisdb.h : Class Definition for an ISIS db
|
---|
| 28 | ////////////////////////////////////////////////////////////
|
---|
| 29 |
|
---|
| 30 | #ifndef __ISISDB_H__
|
---|
| 31 | #define __ISISDB_H__
|
---|
| 32 |
|
---|
| 33 | #include "AbstractIsisDb.h"
|
---|
| 34 | #include "IsisDef.h"
|
---|
| 35 | #ifndef _MFFILE_H_
|
---|
| 36 | #include "MFFile.h"
|
---|
| 37 | #endif
|
---|
| 38 |
|
---|
| 39 |
|
---|
| 40 | class IsisDb : public AbstractIsisDb
|
---|
| 41 | {
|
---|
| 42 | friend class CDBaseFile;
|
---|
| 43 |
|
---|
| 44 | bool bReadOnly_;
|
---|
| 45 | TCHAR xrfname_[_MAX_PATH];
|
---|
| 46 | TCHAR mfname_[_MAX_PATH];
|
---|
| 47 | TCHAR fdtname_[_MAX_PATH];
|
---|
| 48 | TCHAR idxname_[_MAX_PATH];
|
---|
| 49 | protected:
|
---|
| 50 | void MkNames();
|
---|
| 51 | public:
|
---|
| 52 | IsisDb();
|
---|
| 53 | virtual ~IsisDb( );
|
---|
| 54 | int OpenDb(const TCHAR *fname, FileSystem::AccessMode mode =
|
---|
| 55 | FileSystem::FILE_READWRITE);
|
---|
| 56 | int CreateDb(const TCHAR *fname);
|
---|
| 57 |
|
---|
| 58 |
|
---|
| 59 | // Closing the database
|
---|
| 60 | virtual void CloseDb(); // Close the db
|
---|
| 61 |
|
---|
| 62 | virtual void ClearDb() { } // Clear the db
|
---|
| 63 | virtual void DestroyDb() { } // Delete the db
|
---|
| 64 |
|
---|
| 65 | // Recovery
|
---|
| 66 | virtual bool IsDamaged() { return false;} // Test if the database is damaged
|
---|
| 67 | virtual bool Recover() { return true; } // Recover the db
|
---|
| 68 |
|
---|
| 69 | // Transactions
|
---|
| 70 | virtual void BeginTransaction() { } // Begin a transaction
|
---|
| 71 | virtual void CommitTRansaction() { } // Commit a transaction
|
---|
| 72 | virtual void RollbackTransaction() { } // Rollback a transaction
|
---|
| 73 | virtual bool InTransaction() { return false; } // Test if transaction is pending
|
---|
| 74 |
|
---|
| 75 | virtual void CreateIndex(int i) { }
|
---|
| 76 | virtual void DropIndex(int i) { }
|
---|
| 77 |
|
---|
| 78 | void CreateDbRecord(MfRecord &m);
|
---|
| 79 | void CreateDbRecordWithMfn(MfRecord &m);
|
---|
| 80 | void UpdateDbRecord(MfRecord &m);
|
---|
| 81 | bool DeleteRecord(long mfn);
|
---|
| 82 | int ReadDbRecord(long mfn, MfRecord &m);
|
---|
| 83 | int ReadNextDbRecord(MfRecord &m);
|
---|
| 84 | void PrintDbRecord(MfRecord &m);
|
---|
| 85 | void PrintDbHdr();
|
---|
| 86 |
|
---|
| 87 | void SetNextMfn(long mfn) { mf_->setNextMfn(mfn); }
|
---|
| 88 | long GetNextMfn() { return mf_->GetNextMfn(); }
|
---|
| 89 | long GetNextActiveMfn(long mfn=-1);
|
---|
| 90 |
|
---|
| 91 | SMfHeader& GetSMfHeader() { return mf_->GetSMfHeader(); }
|
---|
| 92 | _TCHAR *GetIdxFileName();
|
---|
| 93 |
|
---|
| 94 | bool IsReadOnly() { return bReadOnly_; }
|
---|
| 95 | };
|
---|
| 96 |
|
---|
| 97 | //////////////////////////////
|
---|
| 98 |
|
---|
| 99 | inline int IsisDb::ReadNextDbRecord(MfRecord &m)
|
---|
| 100 | {
|
---|
| 101 | return 1;
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | //////////////////////////////
|
---|
| 105 |
|
---|
| 106 | inline void IsisDb::PrintDbRecord(MfRecord &m)
|
---|
| 107 | {
|
---|
| 108 | mf_->PrintMfRecord(m);
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | //////////////////////////////
|
---|
| 112 |
|
---|
| 113 | inline void IsisDb::PrintDbHdr()
|
---|
| 114 | {
|
---|
| 115 | mf_->PrintMfHdr();
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | ////////////////////////////////////////////////////////////////////////////////
|
---|
| 119 |
|
---|
| 120 | class IsisDbFactory : public AbstractIsisDbFactory
|
---|
| 121 | {
|
---|
| 122 | public:
|
---|
| 123 | virtual AbstractIsisDb* MakeIsisDb() { return new IsisDb(); }
|
---|
| 124 | };
|
---|
| 125 |
|
---|
| 126 | /////////////////////////////////////////////////////////////////////////////////
|
---|
| 127 |
|
---|
| 128 |
|
---|
| 129 |
|
---|
| 130 | #endif
|
---|