1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * OIDtools.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 OIDTOOLS_H
|
---|
28 | #define OIDTOOLS_H
|
---|
29 |
|
---|
30 | #include "text_t.h"
|
---|
31 | #include "recptproto.h"
|
---|
32 |
|
---|
33 | // returns (in top) the top level of OID (i.e. everything
|
---|
34 | // up until the first dot)
|
---|
35 | void get_top (const text_t &OID, text_t &top);
|
---|
36 |
|
---|
37 | // checks if OID is top level (i.e. contains no dots)
|
---|
38 | bool is_top (const text_t &OID);
|
---|
39 |
|
---|
40 | // get_parents_array loads the parents array with all the parents of the
|
---|
41 | // document or classification specified by OID (not including OID itself)
|
---|
42 | void get_parents_array (const text_t &OID, text_tarray &parents);
|
---|
43 |
|
---|
44 | // get_info does a protocol call and returns (in response) the info
|
---|
45 | // associated with OID. Metadata should be loaded with whatever
|
---|
46 | // metadata fields are to be requested
|
---|
47 | bool get_info (const text_t &OID, const text_t &collection,
|
---|
48 | const text_tset &metadata, bool getParents,
|
---|
49 | recptproto *collectproto, FilterResponse_t &response,
|
---|
50 | ostream &logout);
|
---|
51 | bool get_info (const text_t &OID, const text_t &collection,
|
---|
52 | const text_tset &metadata, const OptionValue_tarray &options,
|
---|
53 | bool getParents,
|
---|
54 | recptproto *collectproto, FilterResponse_t &response,
|
---|
55 | ostream &logout);
|
---|
56 | bool get_info (const text_tarray &OIDs, const text_t &collection,
|
---|
57 | const text_tset &metadata, bool getParents,
|
---|
58 | recptproto *collectproto, FilterResponse_t &response,
|
---|
59 | ostream &logout);
|
---|
60 |
|
---|
61 | // has_children returns true if OID has children
|
---|
62 | bool has_children (const text_t &OID, const text_t &collection,
|
---|
63 | recptproto *collectproto, ostream &logout);
|
---|
64 |
|
---|
65 | // get_children does a protocol call and returns (in response) the OIDs and
|
---|
66 | // metadata of all the children of OID. The metadata set should be loaded
|
---|
67 | // with whatever metadata fields are to be requested.
|
---|
68 | bool get_children (const text_t &OID, const text_t &collection,
|
---|
69 | const text_tset &metadata, bool getParents,
|
---|
70 | recptproto *collectproto, FilterResponse_t &response,
|
---|
71 | ostream &logout);
|
---|
72 |
|
---|
73 | // get_parent returns the parent of the document or classification
|
---|
74 | // specified by OID
|
---|
75 | text_t get_parent (text_t OID);
|
---|
76 |
|
---|
77 | // takes an OID like ".2.3 and replaces the " with parent
|
---|
78 | void translate_parent (text_t &OID, const text_t &parent);
|
---|
79 |
|
---|
80 | // shrink_parent does the opposite to translate_parent
|
---|
81 | void shrink_parent (text_t &OID);
|
---|
82 |
|
---|
83 | // checks if OID uses ".fc", ".lc", ".pr", ".ns",
|
---|
84 | // or ".ps" syntax (first child, last child, parent,
|
---|
85 | // next sibling, previous sibling)
|
---|
86 | bool needs_translating (const text_t &OID);
|
---|
87 |
|
---|
88 | // strips the ".fc", ".lc", ".pr", ".ns",
|
---|
89 | // or ".ps" suffix from the end of OID
|
---|
90 | void strip_suffix (text_t &OID);
|
---|
91 |
|
---|
92 | // get_contents returns OIDs and metadata of all contents
|
---|
93 | // below (and including) OID.
|
---|
94 | void get_contents (const text_t &topOID, const bool &is_classify,
|
---|
95 | text_tset &metadata, const text_t &collection,
|
---|
96 | recptproto *collectproto, FilterResponse_t &response,
|
---|
97 | ostream &logout);
|
---|
98 |
|
---|
99 | // is_child_of returns true if OID2 is a child of OID1
|
---|
100 | bool is_child_of(const text_t &OID1, const text_t &OID2);
|
---|
101 |
|
---|
102 |
|
---|
103 | #endif
|
---|