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, outconvertclass &outconvert,
|
---|
22 | bool &headerDone, const text_t &label,
|
---|
23 | const text_tarray &values);
|
---|
24 | virtual void output_metadata_footer(ostream &output) = 0;
|
---|
25 | virtual bool is_valid_element(text_t &meta_name);
|
---|
26 | virtual bool scan_metadata(ostream &output, const text_t &collection,
|
---|
27 | ResultDocInfo_t &docInfo, bool doOutput);
|
---|
28 | virtual bool output_custom_metadata(ostream &output, outconvertclass &outconvert, bool &headerDone, const text_t &collection,
|
---|
29 | ResultDocInfo_t &docInfo);
|
---|
30 | text_t get_metadata_value(ResultDocInfo_t &docInfo, const text_t &meta_name);
|
---|
31 | void get_metadata_values(ResultDocInfo_t &docInfo, const text_t &meta_name, text_tarray & values);
|
---|
32 | oaiconfig * oaiConfigure;
|
---|
33 |
|
---|
34 | // a set containing all the valid element names for the set. Must be
|
---|
35 | // initialized by each metadata class
|
---|
36 | text_tset elementSet;
|
---|
37 |
|
---|
38 | public:
|
---|
39 | metaformat(); // Must be given the desired oai version when created
|
---|
40 | virtual const text_t formatName() = 0;
|
---|
41 | virtual const text_t formatPrefix() = 0;
|
---|
42 | virtual bool output_record(ostream &output, recptproto *protocol,
|
---|
43 | const text_t &collection,
|
---|
44 | const text_t &record_OID);
|
---|
45 | virtual bool is_available(const text_t &collection, ResultDocInfo_t &docInfo);
|
---|
46 | virtual bool output_metadata(ostream &output, const text_t &collection,
|
---|
47 | ResultDocInfo_t &docInfo);
|
---|
48 | virtual bool output_formatdata(ostream &output) = 0;
|
---|
49 | void set_configuration(oaiconfig *config) { this->oaiConfigure = config; }
|
---|
50 | text_t get_mapping(const text_t &collection, const text_t &collectionField);
|
---|
51 | virtual ~metaformat() { this->oaiConfigure = NULL; }
|
---|
52 | };
|
---|
53 |
|
---|
54 | class metaformatptr
|
---|
55 | {
|
---|
56 | public:
|
---|
57 | metaformat *ptr;
|
---|
58 |
|
---|
59 | metaformatptr() { this->ptr = NULL; }
|
---|
60 | metaformat *get_class() { return this->ptr; }
|
---|
61 | void set_class(metaformat *ptr) { this->ptr = ptr; }
|
---|
62 | void set_configuration(oaiconfig *config) { this->ptr->set_configuration(config);}
|
---|
63 | void clear() { delete this->ptr; this->ptr = NULL; }
|
---|
64 | };
|
---|
65 |
|
---|
66 | typedef map<text_t, metaformatptr, lttext_t> metaformat_map;
|
---|
67 |
|
---|
68 | #endif
|
---|