1 | /**
|
---|
2 | * A framework class for metadata formats.
|
---|
3 | *
|
---|
4 | * Example child classes include oaimeta and rfc8507meta
|
---|
5 | */
|
---|
6 |
|
---|
7 | #ifndef _METAFORMAT_H_
|
---|
8 | #define _METAFORMAT_H_
|
---|
9 | #include <stdio.h>
|
---|
10 |
|
---|
11 | #include "text_t.h"
|
---|
12 | #include "comtypes.h"
|
---|
13 | #include "recptproto.h"
|
---|
14 |
|
---|
15 | #include "oaiconfig.h"
|
---|
16 |
|
---|
17 | class metaformat
|
---|
18 | {
|
---|
19 | protected:
|
---|
20 | virtual void output_metadata_header(ostream &output) = 0;
|
---|
21 | virtual void output_item(ostream &output, bool &headerDone, const text_t &label,
|
---|
22 | const text_tarray &values);
|
---|
23 | virtual void output_metadata_footer(ostream &output) = 0;
|
---|
24 | virtual bool scan_metadata(ostream &output, const text_t &collection, ResultDocInfo_t &docInfo,
|
---|
25 | bool doOutput);
|
---|
26 | oaiconfig * oaiConfigure;
|
---|
27 |
|
---|
28 | public:
|
---|
29 | metaformat(); // Must be given the desired oai version when created
|
---|
30 | virtual const text_t formatName() = 0;
|
---|
31 | virtual const text_t formatPrefix() = 0;
|
---|
32 | virtual bool output_record(ostream &output, recptproto *protocol, const text_t &collection,
|
---|
33 | const text_t &record_OID);
|
---|
34 | virtual bool is_available(const text_t &collection, ResultDocInfo_t &docInfo);
|
---|
35 | virtual bool output_metadata(ostream &output, const text_t &collection, ResultDocInfo_t &docInfo);
|
---|
36 | virtual bool output_formatdata(ostream &output) = 0;
|
---|
37 | void set_configuration(oaiconfig *config) { this->oaiConfigure = config; }
|
---|
38 | text_t get_mapping(const text_t &collection, const text_t &collectionField);
|
---|
39 |
|
---|
40 | };
|
---|
41 |
|
---|
42 | class metaformatptr
|
---|
43 | {
|
---|
44 | public:
|
---|
45 | metaformat *ptr;
|
---|
46 |
|
---|
47 | metaformatptr() { this->ptr = NULL; }
|
---|
48 | metaformat *get_class() { return this->ptr; }
|
---|
49 | void set_class(metaformat *ptr) { this->ptr = ptr; }
|
---|
50 | void set_configuration(oaiconfig *config) { this->ptr->set_configuration(config);}
|
---|
51 | void clear() { delete this->ptr; this->ptr = NULL; }
|
---|
52 | };
|
---|
53 |
|
---|
54 | typedef map<text_t, metaformatptr> metaformat_map;
|
---|
55 |
|
---|
56 | #endif
|
---|