root/main/trunk/greenstone2/runtime-src/src/oaiservr/metaformat.h @ 22739

Revision 22739, 3.5 KB (checked in by mdewsnip, 9 years ago)

Added copyright header to runtime-src/src/oaiserver/*.cpp and runtime-src/src/oaiserver/*.h.

  • Property svn:keywords set to Author Date Id Revision
Line 
1/**********************************************************************
2 *
3 * metaformat.h --
4 *
5 * Copyright (C) 2004-2010  The New Zealand Digital Library Project
6 *
7 * A component of the Greenstone digital library software
8 * from the New Zealand Digital Library Project at the
9 * University of Waikato, New Zealand.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 *********************************************************************/
26
27/**
28 *  A framework class for metadata formats.
29 *
30 *  Example child classes include oaimeta and rfc8507meta
31 */
32
33#ifndef _METAFORMAT_H_
34#define _METAFORMAT_H_
35#include <stdio.h>
36
37#include "text_t.h"
38#include "comtypes.h"
39#include "recptproto.h"
40
41#include "oaiconfig.h"
42
43class metaformat
44
45 protected:
46  virtual void output_metadata_header(ostream &output) = 0;
47  virtual void output_item(ostream &output, outconvertclass &outconvert,
48               bool &headerDone, const text_t &label,
49               const text_tarray &values);
50  virtual void output_metadata_footer(ostream &output) = 0;
51  virtual bool is_valid_element(text_t &meta_name);
52  virtual bool scan_metadata(ostream &output, const text_t &collection, 
53                 ResultDocInfo_t &docInfo, bool doOutput);
54  virtual bool output_custom_metadata(ostream &output, outconvertclass &outconvert, bool &headerDone, const text_t &collection,
55                   ResultDocInfo_t &docInfo);
56  text_t get_metadata_value(ResultDocInfo_t &docInfo, const text_t &meta_name);
57  void get_metadata_values(ResultDocInfo_t &docInfo, const text_t &meta_name, text_tarray & values);
58  oaiconfig *    oaiConfigure;
59
60  // a set containing all the valid element names for the set. Must be
61  // initialized by each metadata class
62  text_tset elementSet;
63
64 public:
65  metaformat(); // Must be given the desired oai version when created
66  virtual const text_t formatName() = 0;
67  virtual const text_t formatPrefix() = 0;
68  virtual bool output_record(ostream &output, recptproto *protocol,
69                 const text_t &collection,
70                 const text_t &record_OID);
71  virtual bool is_available(const text_t &collection, ResultDocInfo_t &docInfo);
72  virtual bool output_metadata(ostream &output, const text_t &collection, 
73                   ResultDocInfo_t &docInfo);
74  virtual bool output_formatdata(ostream &output) = 0;
75  void    set_configuration(oaiconfig *config) { this->oaiConfigure = config; }
76  text_t  get_mapping(const text_t &collection, const text_t &collectionField);
77  virtual ~metaformat() { this->oaiConfigure = NULL; }
78};
79
80class metaformatptr
81{
82 public:
83  metaformat *ptr;
84
85  metaformatptr() { this->ptr = NULL; }
86  metaformat *get_class() { return this->ptr; }
87  void set_class(metaformat *ptr) { this->ptr = ptr; }
88  void set_configuration(oaiconfig *config) { this->ptr->set_configuration(config);}
89  void clear() { delete this->ptr; this->ptr = NULL; }
90};
91
92typedef map<text_t, metaformatptr, lttext_t> metaformat_map;
93
94#endif
Note: See TracBrowser for help on using the browser.