source: trunk/gsdl/src/colservr/collectserver.cpp@ 166

Last change on this file since 166 was 166, checked in by rjmcnab, 25 years ago

Initial revision.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1/**********************************************************************
2 *
3 * collectserver.cpp --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * PUT COPYRIGHT NOTICE HERE
7 *
8 * $Id: collectserver.cpp 166 1999-02-21 22:35:26Z rjmcnab $
9 *
10 *********************************************************************/
11
12/*
13 $Log$
14 Revision 1.1 1999/02/21 22:32:56 rjmcnab
15
16 Initial revision.
17
18 */
19
20
21#include "collectserver.h"
22#include <assert.h>
23
24
25collectserver::collectserver () {
26 configinfo.collection = "null";
27}
28
29collectserver::~collectserver () {
30}
31
32// configure should be called for each line in the
33// configuration files to configure the collection server and everything
34// it contains. The configuration should take place just before initialisation.
35void collectserver::configure (const text_t &key, const text_tarray &cfgline) {
36 // configure the collection server
37 if (cfgline.size() >= 1) {
38 const text_t &value = cfgline[0];
39 if (key == "gsdlhome") configinfo.gsdlhome = value;
40 else if (key == "collection") {
41 configinfo.collection = value;
42 collectinfo.shortInfo.name = value;
43 } else if (key == "collectdir") configinfo.collectdir = value;
44 else if (key == "host") collectinfo.shortInfo.host = value;
45 else if (key == "port") collectinfo.shortInfo.port = value.getint();
46 else if (key == "public") {
47 if (value == "true") collectinfo.isPublic = true;
48 else collectinfo.isPublic = false;
49 } else if (key == "beta") {
50 if (value == "true") collectinfo.isBeta = true;
51 else collectinfo.isBeta = false;
52 } else if (key == "builddate") collectinfo.buildDate = value.getint();
53 else if (key == "languages") collectinfo.languages = cfgline;
54 else if (key == "numdocs") collectinfo.numDocs = value.getint();
55 else if (key == "numwords") collectinfo.numWords = value.getint();
56 else if (key == "numbytes") collectinfo.numBytes = value.getint();
57 }
58}
59
60void collectserver::configure (const text_t &key, const text_t &value) {
61 text_tarray cfgline;
62 cfgline.push_back (value);
63 configure(key, cfgline);
64}
65
66
67bool collectserver::init (ostream &/*logout*/) {
68 return true;
69}
70
71
72
73// thecollectserver remains the property of the calling code but
74// should not be deleted until it is removed from this list.
75void collectservermapclass::addcollectserver (collectserver *thecollectserver) {
76 // can't add a null collection server
77 assert (thecollectserver != NULL);
78 if (thecollectserver == NULL) return;
79
80 // can't add an collection server with no collection name
81 assert (!(thecollectserver->get_collection_name()).empty());
82 if ((thecollectserver->get_collection_name()).empty()) return;
83
84 collectserverptr cptr;
85 cptr.c = thecollectserver;
86 collectserverptrs[thecollectserver->get_collection_name()] = cptr;
87}
88
89// getcollectserver will return NULL if the collectserver could not be found
90collectserver *collectservermapclass::getcollectserver (const text_t &collection) {
91 // can't find a collection with no name
92 assert (!collection.empty());
93 if (collection.empty()) return NULL;
94
95 iterator here = collectserverptrs.find (collection);
96 if (here == collectserverptrs.end()) return NULL;
97
98 return (*here).second.c;
99}
100
Note: See TracBrowser for help on using the repository browser.