source: main/trunk/greenstone2/runtime-src/src/colservr/source.h@ 31388

Last change on this file since 31388 was 31388, checked in by ak19, 7 years ago

Second commit to do with implementing OAI deletion policy for GS2. This commit is only loosely related, as it shifts functions duplicated in source.h and filter.h (and cpp files) into the new colserver.h and cpp files for sharing.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.4 KB
Line 
1/**********************************************************************
2 *
3 * source.h --
4 * Copyright (C) 1999 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
27#ifndef SOURCE_H
28#define SOURCE_H
29
30#include "gsdlconf.h"
31#include "text_t.h"
32#include "dbclass.h"
33#include "search.h"
34#include "comtypes.h"
35#include "maptools.h"
36
37
38class sourceclass {
39protected:
40 text_t classname;
41
42 text_t gsdlhome;
43 text_t collecthome;
44 text_t dbhome;
45 text_t collection;
46 text_t collectdir;
47
48 stringmap indexmap;
49 stringmap subcollectionmap;
50 stringmap languagemap;
51
52 text_t defaultindex;
53 text_t defaultsubcollection;
54 text_t defaultlanguage;
55
56 text_t indexstem;
57
58 text_t parentOID;
59 infodbclass parentinfo;
60 text_tarray parentcontents;
61
62 text_t db_filename;
63 dbclass *db_ptr;
64 text_t oaidb_filename;
65 dbclass *oaidb_ptr;
66
67 searchclass *textsearchptr;
68
69public:
70 sourceclass ();
71 virtual ~sourceclass ();
72
73 // the DB ptrs remain the responsibility of the calling code
74 // but as the db_ptr is deleted by this source object, the oaidb_ptr will be deleted by this object too
75 void set_db_ptr (dbclass *db_ptr_arg) { db_ptr = db_ptr_arg; }
76 void set_oaidb_ptr (dbclass *oaidb_ptr_arg) { oaidb_ptr = oaidb_ptr_arg; }
77
78 // the textsearchptr remains the responsibility of the calling code
79 void set_textsearchptr (searchclass *textsearchptr_arg) { textsearchptr = textsearchptr_arg; }
80
81 // configure should be called once for each configuration line
82 virtual void configure (const text_t &key, const text_tarray &cfgline);
83
84 // init should be called after all the configuration is done but
85 // before any other methods are called
86 virtual bool init (ostream &logout);
87
88 // translate_OID translates OIDs using ".pr", ."fc" etc.
89 virtual bool translate_OID (const text_t &OIDin, text_t &OIDout,
90 comerror_t &err, ostream &logout);
91
92 // get_metadata fills out the metadata if possible.
93 // If it is not responsible for the given OID then it will return false.
94 virtual bool get_metadata (const text_t &requestParams, const text_t &refParams,
95 bool getParents, const text_tset &fields,
96 const text_t &OID, MetadataInfo_tmap &metadata,
97 comerror_t &err, ostream &logout, bool append);
98
99 // get_oai_metadata fills out the metadata from the oai_db if possible
100 // if it is not responsible for the given OID then it will return false.
101 virtual bool get_oai_metadata (const text_t &requestParams, const text_t &refParams,
102 bool getParents, const text_tset &fields,
103 const text_t &OID, text_t &deleted_status,
104 MetadataInfo_tmap &metadata, comerror_t &err, ostream &logout);
105
106 virtual bool get_document (const text_t &OID, text_t &doc,
107 comerror_t &err, ostream &logout);
108
109 virtual bool is_searchable(bool &issearchable, comerror_t &err, ostream &logout);
110
111};
112
113
114// The sourceptr class does not 'own' the source. The
115// source should be deleted by the code which created it.
116class sourceptr {
117public:
118 sourceclass *s;
119
120 sourceptr () {s=NULL;}
121 ~sourceptr () {}
122};
123
124bool operator==(const sourceptr &x, const sourceptr &y);
125bool operator<(const sourceptr &x, const sourceptr &y);
126
127typedef vector<sourceptr> sourceptrlist;
128
129// contains a list of sources
130class sourcelistclass {
131protected:
132 sourceptrlist sourceptrs;
133
134public:
135 // type support for sourcelistclass
136 typedef sourceptrlist::iterator iterator;
137 typedef sourceptrlist::const_iterator const_iterator;
138 typedef sourceptrlist::reference reference;
139 typedef sourceptrlist::const_reference const_reference;
140 typedef sourceptrlist::size_type size_type;
141
142 typedef sourceptrlist::difference_type difference_type;
143 typedef sourceptrlist::const_reverse_iterator const_reverse_iterator;
144 typedef sourceptrlist::reverse_iterator reverse_iterator;
145
146 // basic container support
147 iterator begin () {return sourceptrs.begin();}
148 const_iterator begin () const {return sourceptrs.begin();}
149 iterator end () {return sourceptrs.end();}
150 const_iterator end () const {return sourceptrs.end();}
151
152 void erase(iterator pos) {sourceptrs.erase(pos);}
153 void erase(iterator first, iterator last) {sourceptrs.erase(first, last);}
154 sourcelistclass &operator=(const sourcelistclass &x)
155 {sourceptrs=x.sourceptrs;return *this;}
156
157 bool empty () const {return sourceptrs.empty();}
158 size_type size() const {return sourceptrs.size();}
159
160
161 // added functionality
162 void clear () {sourceptrs.erase(sourceptrs.begin(),sourceptrs.end());}
163
164 // thesource remains the property of the calling code but
165 // should not be deleted until it is removed from this list.
166 void addsource (sourceclass *thesource);
167};
168
169
170
171#endif
Note: See TracBrowser for help on using the repository browser.