1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * source.h --
|
---|
4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
5 | *
|
---|
6 | * PUT COPYRIGHT NOTICE HERE
|
---|
7 | *
|
---|
8 | * $Id: source.h 271 1999-06-16 02:00:34Z sjboddie $
|
---|
9 | *
|
---|
10 | *********************************************************************/
|
---|
11 |
|
---|
12 |
|
---|
13 | #ifndef SOURCE_H
|
---|
14 | #define SOURCE_H
|
---|
15 |
|
---|
16 | #include "gsdlconf.h"
|
---|
17 | #include "text_t.h"
|
---|
18 | #include "comtypes.h"
|
---|
19 |
|
---|
20 |
|
---|
21 | class sourceclass {
|
---|
22 | public:
|
---|
23 | sourceclass ();
|
---|
24 | virtual ~sourceclass ();
|
---|
25 |
|
---|
26 | // configure should be called once for each configuration line
|
---|
27 | virtual void configure (const text_t &key, const text_tarray &cfgline);
|
---|
28 |
|
---|
29 | // init should be called after all the configuration is done but
|
---|
30 | // before any other methods are called
|
---|
31 | virtual bool init (ostream &logout);
|
---|
32 |
|
---|
33 | // translate_OID translates OIDs using ".pr", ."fc" etc.
|
---|
34 | virtual bool translate_OID (const text_t &OIDin, text_t &OIDout,
|
---|
35 | comerror_t &err, ostream &logout);
|
---|
36 |
|
---|
37 | // get_metadata fills out the metadata if possible, if it is not responsable
|
---|
38 | // for the given OID then it will return false.
|
---|
39 | virtual bool get_metadata (const text_t &requestParams, const text_t &refParams,
|
---|
40 | bool getParents, const text_tarray &fields, const text_t &OID,
|
---|
41 | MetadataInfo_tarray &metadata, comerror_t &err, ostream &logout);
|
---|
42 |
|
---|
43 | virtual bool get_document (const text_t &OID, text_t &doc,
|
---|
44 | comerror_t &err, ostream &logout);
|
---|
45 | };
|
---|
46 |
|
---|
47 |
|
---|
48 | // The sourceptr class does not 'own' the source. The
|
---|
49 | // source should be deleted by the code which created it.
|
---|
50 | class sourceptr {
|
---|
51 | public:
|
---|
52 | sourceclass *s;
|
---|
53 |
|
---|
54 | sourceptr () {s=NULL;}
|
---|
55 | };
|
---|
56 |
|
---|
57 | typedef vector<sourceptr> sourceptrlist;
|
---|
58 |
|
---|
59 | // contains a list of sources
|
---|
60 | class sourcelistclass {
|
---|
61 | protected:
|
---|
62 | sourceptrlist sourceptrs;
|
---|
63 |
|
---|
64 | public:
|
---|
65 | // type support for sourcelistclass
|
---|
66 | typedef sourceptrlist::iterator iterator;
|
---|
67 | typedef sourceptrlist::const_iterator const_iterator;
|
---|
68 | typedef sourceptrlist::reference reference;
|
---|
69 | typedef sourceptrlist::const_reference const_reference;
|
---|
70 | typedef sourceptrlist::size_type size_type;
|
---|
71 |
|
---|
72 | typedef sourceptrlist::difference_type difference_type;
|
---|
73 | typedef sourceptrlist::const_reverse_iterator const_reverse_iterator;
|
---|
74 | typedef sourceptrlist::reverse_iterator reverse_iterator;
|
---|
75 |
|
---|
76 | // basic container support
|
---|
77 | iterator begin () {return sourceptrs.begin();}
|
---|
78 | const_iterator begin () const {return sourceptrs.begin();}
|
---|
79 | iterator end () {return sourceptrs.end();}
|
---|
80 | const_iterator end () const {return sourceptrs.end();}
|
---|
81 |
|
---|
82 | void erase(iterator pos) {sourceptrs.erase(pos);}
|
---|
83 | void erase(iterator first, iterator last) {sourceptrs.erase(first, last);}
|
---|
84 | sourcelistclass &operator=(const sourcelistclass &x)
|
---|
85 | {sourceptrs=x.sourceptrs;return *this;}
|
---|
86 |
|
---|
87 | bool empty () const {return sourceptrs.empty();}
|
---|
88 | size_type size() const {return sourceptrs.size();}
|
---|
89 |
|
---|
90 |
|
---|
91 | // added functionality
|
---|
92 | void clear () {sourceptrs.erase(sourceptrs.begin(),sourceptrs.end());}
|
---|
93 |
|
---|
94 | // thesource remains the property of the calling code but
|
---|
95 | // should not be deleted until it is removed from this list.
|
---|
96 | void addsource (sourceclass *thesource);
|
---|
97 | };
|
---|
98 |
|
---|
99 |
|
---|
100 |
|
---|
101 | #endif
|
---|