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

Last change on this file since 543 was 534, checked in by sjboddie, 25 years ago

added gpl notice

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.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 * $Id: source.h 534 1999-09-07 04:57:43Z sjboddie $
25 *
26 *********************************************************************/
27
28
29#ifndef SOURCE_H
30#define SOURCE_H
31
32#include "gsdlconf.h"
33#include "text_t.h"
34#include "comtypes.h"
35
36
37class sourceclass {
38public:
39 sourceclass ();
40 virtual ~sourceclass ();
41
42 // configure should be called once for each configuration line
43 virtual void configure (const text_t &key, const text_tarray &cfgline);
44
45 // init should be called after all the configuration is done but
46 // before any other methods are called
47 virtual bool init (ostream &logout);
48
49 // translate_OID translates OIDs using ".pr", ."fc" etc.
50 virtual bool translate_OID (const text_t &OIDin, text_t &OIDout,
51 comerror_t &err, ostream &logout);
52
53 // get_metadata fills out the metadata if possible, if it is not responsable
54 // for the given OID then it will return false.
55 virtual bool get_metadata (const text_t &requestParams, const text_t &refParams,
56 bool getParents, const text_tarray &fields, const text_t &OID,
57 MetadataInfo_tarray &metadata, comerror_t &err, ostream &logout);
58
59 virtual bool get_document (const text_t &OID, text_t &doc,
60 comerror_t &err, ostream &logout);
61};
62
63
64// The sourceptr class does not 'own' the source. The
65// source should be deleted by the code which created it.
66class sourceptr {
67public:
68 sourceclass *s;
69
70 sourceptr () {s=NULL;}
71 ~sourceptr () {}
72};
73
74bool operator==(const sourceptr &x, const sourceptr &y);
75bool operator<(const sourceptr &x, const sourceptr &y);
76
77typedef vector<sourceptr> sourceptrlist;
78
79// contains a list of sources
80class sourcelistclass {
81protected:
82 sourceptrlist sourceptrs;
83
84public:
85 // type support for sourcelistclass
86 typedef sourceptrlist::iterator iterator;
87 typedef sourceptrlist::const_iterator const_iterator;
88 typedef sourceptrlist::reference reference;
89 typedef sourceptrlist::const_reference const_reference;
90 typedef sourceptrlist::size_type size_type;
91
92 typedef sourceptrlist::difference_type difference_type;
93 typedef sourceptrlist::const_reverse_iterator const_reverse_iterator;
94 typedef sourceptrlist::reverse_iterator reverse_iterator;
95
96 // basic container support
97 iterator begin () {return sourceptrs.begin();}
98 const_iterator begin () const {return sourceptrs.begin();}
99 iterator end () {return sourceptrs.end();}
100 const_iterator end () const {return sourceptrs.end();}
101
102 void erase(iterator pos) {sourceptrs.erase(pos);}
103 void erase(iterator first, iterator last) {sourceptrs.erase(first, last);}
104 sourcelistclass &operator=(const sourcelistclass &x)
105 {sourceptrs=x.sourceptrs;return *this;}
106
107 bool empty () const {return sourceptrs.empty();}
108 size_type size() const {return sourceptrs.size();}
109
110
111 // added functionality
112 void clear () {sourceptrs.erase(sourceptrs.begin(),sourceptrs.end());}
113
114 // thesource remains the property of the calling code but
115 // should not be deleted until it is removed from this list.
116 void addsource (sourceclass *thesource);
117};
118
119
120
121#endif
Note: See TracBrowser for help on using the repository browser.