source: main/tags/2.31/gsdl/src/colservr/source.h@ 25382

Last change on this file since 25382 was 1285, checked in by sjboddie, 24 years ago

Removed CVS logging information from source files

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