source: gsdl/trunk/src/colservr/source.h@ 16445

Last change on this file since 16445 was 16310, checked in by davidb, 16 years ago

Introduction of 'collecthome' which parallels 'gsdlhome' to allow the toplevel collect folder to be outside of the gsdlhome area

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 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
65 searchclass *textsearchptr;
66
67public:
68 sourceclass ();
69 virtual ~sourceclass ();
70
71 // the DB ptr remains the responsibility of the calling code
72 void set_db_ptr (dbclass *db_ptr_arg) { db_ptr = db_ptr_arg; }
73
74 // the textsearchptr remains the responsibility of the calling code
75 void set_textsearchptr (searchclass *textsearchptr_arg) { textsearchptr = textsearchptr_arg; }
76
77 // configure should be called once for each configuration line
78 virtual void configure (const text_t &key, const text_tarray &cfgline);
79
80 // init should be called after all the configuration is done but
81 // before any other methods are called
82 virtual bool init (ostream &logout);
83
84 // translate_OID translates OIDs using ".pr", ."fc" etc.
85 virtual bool translate_OID (const text_t &OIDin, text_t &OIDout,
86 comerror_t &err, ostream &logout);
87
88 // get_metadata fills out the metadata if possible, if it is not responsable
89 // for the given OID then it will return false.
90 virtual bool get_metadata (const text_t &requestParams, const text_t &refParams,
91 bool getParents, const text_tset &fields,
92 const text_t &OID, MetadataInfo_tmap &metadata,
93 comerror_t &err, ostream &logout);
94
95 virtual bool get_document (const text_t &OID, text_t &doc,
96 comerror_t &err, ostream &logout);
97
98 virtual bool is_searchable(bool &issearchable, comerror_t &err, ostream &logout);
99
100 protected:
101 text_t resolve_db_filename(const text_t& idx,
102 const text_t& file_ext);
103
104};
105
106
107// The sourceptr class does not 'own' the source. The
108// source should be deleted by the code which created it.
109class sourceptr {
110public:
111 sourceclass *s;
112
113 sourceptr () {s=NULL;}
114 ~sourceptr () {}
115};
116
117bool operator==(const sourceptr &x, const sourceptr &y);
118bool operator<(const sourceptr &x, const sourceptr &y);
119
120typedef vector<sourceptr> sourceptrlist;
121
122// contains a list of sources
123class sourcelistclass {
124protected:
125 sourceptrlist sourceptrs;
126
127public:
128 // type support for sourcelistclass
129 typedef sourceptrlist::iterator iterator;
130 typedef sourceptrlist::const_iterator const_iterator;
131 typedef sourceptrlist::reference reference;
132 typedef sourceptrlist::const_reference const_reference;
133 typedef sourceptrlist::size_type size_type;
134
135 typedef sourceptrlist::difference_type difference_type;
136 typedef sourceptrlist::const_reverse_iterator const_reverse_iterator;
137 typedef sourceptrlist::reverse_iterator reverse_iterator;
138
139 // basic container support
140 iterator begin () {return sourceptrs.begin();}
141 const_iterator begin () const {return sourceptrs.begin();}
142 iterator end () {return sourceptrs.end();}
143 const_iterator end () const {return sourceptrs.end();}
144
145 void erase(iterator pos) {sourceptrs.erase(pos);}
146 void erase(iterator first, iterator last) {sourceptrs.erase(first, last);}
147 sourcelistclass &operator=(const sourcelistclass &x)
148 {sourceptrs=x.sourceptrs;return *this;}
149
150 bool empty () const {return sourceptrs.empty();}
151 size_type size() const {return sourceptrs.size();}
152
153
154 // added functionality
155 void clear () {sourceptrs.erase(sourceptrs.begin(),sourceptrs.end());}
156
157 // thesource remains the property of the calling code but
158 // should not be deleted until it is removed from this list.
159 void addsource (sourceclass *thesource);
160};
161
162
163
164#endif
Note: See TracBrowser for help on using the repository browser.