source: main/trunk/greenstone2/build-src/packages/isis-gdl/AbstractIsisDb.h@ 26670

Last change on this file since 26670 was 6127, checked in by mdewsnip, 20 years ago

IsisGdl package for reading CDS/ISIS databases. Provided by Jean-Claude Dauphin at UNESCO, and modified slightly to compile and run under Linux.

  • Property svn:keywords set to Author Date Id Revision
File size: 6.5 KB
Line 
1/**********************************************************************
2 *
3 * AbstractIsisDb.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// AbstractIsisDb.h -- Abstract Base Class Definitions for an ISIS db
28//
29//
30// The objective is to provide an interface for creating families of Isis
31// db without specifying their concrete classes.
32// ABSTRACT FACTORY PATTERN is used.
33//
34// Author: J-C Dauphin, UNESCO, August 2000
35///////////////////////////////////////////////////////////////////////////////////
36
37#ifndef __ABSTRACT_ISISDB_H__
38#define __ABSTRACT_ISISDB_H__
39
40#include <vector>
41#include "IsisDef.h"
42#include "mytchar.h"
43
44
45///////////////////////////////////////////////////////////////////////////////////
46// Abstract Base Class, set the DB interface. All db concrete classes must be
47// derived from this class.
48//
49// Note that this abstract base class can be extended by specifying abstract base
50// classes for class class MfFile, class XrfFile, class CFdtCWorksheet,
51// class CDisplayFormat, class CFieldSelectTable, class CSortTable,
52// class MfRecord and struct SMfHeader. Pure virtual methods would then be added
53// in the class AbstractIsisDbFactory:
54//
55// virtual AbstractMfFile* makeMfFile() = 0;
56// virtual AbstractXrfFile* makeXrfFile() = 0;
57// ................
58
59
60class MfFile;
61class XrfFile;
62class CFdt; // Forward
63
64class CWorksheet;
65class CDisplayFormat;
66class CFieldSelectTable;
67class CSortTable;
68class MfRecord;
69struct SMfHeader;
70
71class AbstractIsisDb
72{
73protected:
74 ustring name;
75
76 MfFile* mf_; // Has-a master file
77 XrfFile* xf_; // Has-a cross ref file
78 CFdt* fdt_; // Has-a FDT
79
80 std::vector<CWorksheet*> apWS_; // Worksheets
81 std::vector<CDisplayFormat*> apDFMT_; // Display formats
82 std::vector<CFieldSelectTable*> apFST_; // Field Select Tables
83 std::vector<CSortTable*> apST_; // Sort Tables
84
85public:
86 AbstractIsisDb() { }; // Trivial default C++ constructor
87 virtual ~AbstractIsisDb() { }; // Trivial C++ destructor
88
89// Opening the database
90 virtual int OpenDb(const TCHAR *fname, FileSystem::AccessMode mode =
91 FileSystem::FILE_READWRITE) = 0;
92// Creating the database
93 virtual int CreateDb(const TCHAR* fname) = 0;
94
95// Closing the database
96 virtual void CloseDb() = 0; // Close the db
97 virtual void ClearDb() = 0; // Clear the db
98 virtual void DestroyDb() = 0; // Delete the db
99
100// Recovery
101 virtual bool IsDamaged() = 0; // Test if the database is damaged
102 virtual bool Recover() = 0; // Recover the db
103
104// Transactions
105 virtual void BeginTransaction() = 0; // Begin a transaction
106 virtual void CommitTRansaction() = 0; // Commit a transaction
107 virtual void RollbackTransaction() = 0; // Rollback a transaction
108 virtual bool InTransaction() = 0; // Test if transaction is pending
109
110// (FDT)
111 virtual void SetFdt(CFdt *pFdt) { fdt_ = pFdt; }
112 virtual CFdt* GetFdt() { return fdt_; }
113
114// worksheets (WORKSHEETS).
115// (used to create/update the master records of the db)
116 virtual void SetWorksheetAt(int i, CWorksheet* pWS) { apWS_.insert(apWS_.begin()+i, pWS); }
117 virtual CWorksheet* GetWorksheetAt(int i) { return apWS_[i]; }
118 virtual void RemoveWorksheetAt(int i) { apWS_.erase(apWS_.begin()+i); }
119
120// display formats (DISPLAY FORMATS).
121// (used for specifying the formatting requirements for either on-line
122// display of records during searching or for the generation of printed
123// output documents.
124 virtual void SetDisplayFormatAt(int i, CDisplayFormat* pDFMT) { apDFMT_.insert(apDFMT_.begin()+i, pDFMT); }
125 virtual CDisplayFormat* GetDisplayFormatAt(int i) { return apDFMT_[i]; }
126 virtual void RemoveDisplayFormatAt(int i) { apDFMT_.erase(apDFMT_.begin()+i); }
127
128// Field Select Table (FST).
129// One FST defines the fields of the database to be made searchable
130// through the inverted dile.
131 virtual void SetFieldSelectTableAt(int i, CFieldSelectTable* pFST) { apFST_.insert(apFST_.begin()+i, pFST); }
132 virtual CFieldSelectTable* GetFieldSelectTableAt(int i) { return apFST_[i]; }
133 virtual void RemoveFieldSelectTableAt(int i) { apFST_.erase(apFST_.begin()+i); }
134
135 virtual void CreateIndex(int i) = 0;
136 virtual void DropIndex(int i) = 0;
137
138// Sort Select Table (SST).
139// One FST defines the fields of the database to be made searchable
140// through the inverted dile.
141
142 virtual void SetSortTableAt(int i, CSortTable* pST) { apST_.insert(apST_.begin()+i, pST); }
143 virtual CSortTable* GetSortTableAt(int i) { return apST_[i]; }
144 virtual void RemoveSortTableAt(int i) { apST_.erase(apST_.begin()+i); }
145
146 virtual void CreateDbRecord(MfRecord &m) = 0;
147 virtual void UpdateDbRecord(MfRecord &m) = 0;
148
149 virtual int ReadDbRecord(long mfn, MfRecord &m) = 0;
150 virtual int ReadNextDbRecord(MfRecord &m) = 0;
151
152 virtual bool DeleteRecord(long mfn) = 0;
153
154 virtual void PrintDbRecord(MfRecord &m) = 0;
155 virtual void PrintDbHdr() = 0;
156
157 virtual long GetNextMfn() = 0;
158 virtual long GetNextActiveMfn(long mfn=-1) = 0;
159
160 virtual SMfHeader& GetSMfHeader() = 0;
161 virtual _TCHAR *GetIdxFileName() = 0;
162
163
164};
165
166class AbstractIsisDbFactory
167{
168public:
169 virtual AbstractIsisDb* MakeIsisDb() = 0;
170};
171#endif // __ABSTRACT_ISISDB_H__
Note: See TracBrowser for help on using the repository browser.