source: trunk/gsdl/src/recpt/recptproto.h@ 173

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

Initial revision.

  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1/**********************************************************************
2 *
3 * recptproto.h --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * PUT COPYRIGHT NOTICE HERE
7 *
8 * $Id: recptproto.h 166 1999-02-21 22:35:26Z rjmcnab $
9 *
10 *********************************************************************/
11
12
13#ifndef RECPTPROTO_H
14#define RECPTPROTO_H
15
16#include "gsdlconf.h"
17#include "text_t.h"
18#include "comtypes.h"
19
20#if defined(GSDL_USE_OBJECTSPACE)
21# include <ospace\std\vector>
22#elif defined(GSDL_USE_STL_H)
23# include <vector.h>
24#else
25# include <vector>
26#endif
27
28#if defined(GSDL_USE_OBJECTSPACE)
29# include <ospace\std\iostream>
30#elif defined(GSDL_USE_IOS_H)
31# include <iostream.h>
32#else
33# include <iostream>
34#endif
35
36
37// recptproto is a generalisation of a protocol for communicating
38// with a collection server.
39class recptproto {
40public:
41 // configure should be called for each line in the configuration file
42 virtual void configure (const text_t &key, const text_tarray &cfgline);
43
44 // init should be called after the configuration but before any other
45 // functions are called. If init returns false a message will be written
46 // out to the log file and no other output should be produced.
47 virtual bool init (ostream &logout);
48
49 // get_protocol_name should return the name of this protocol (e.g. recptproto)
50 // that can be used to do run time type identification and display information
51 // about the protocol.
52 virtual text_t get_protocol_name ();
53
54 // get_collection_list returns the list of collections that
55 // this protocol knows about
56 virtual void get_collection_list (text_tarray &collist, comerror_t &err,
57 ostream &logout);
58
59 // has_collection sets 'hascollection' to be true if the protocol
60 // can communicate with the collection (i.e. it is within its
61 // collection list). This function should be implemented in as
62 // efficient time as possible as it will be called for each page
63 // access and for each protocol.
64 virtual void has_collection (const text_t &collection, bool &hascollection,
65 comerror_t &err, ostream &logout);
66
67 // sets 'wassuccess' to be true if a successful ping was done to
68 // the given collection.
69 virtual void ping (const text_t &collection, bool &wassuccess,
70 comerror_t &err, ostream &logout);
71
72 // obtains general information about the collection
73 virtual void get_collectinfo (const text_t &collection,
74 ColInfoResponse_t &collectinfo,
75 comerror_t &err, ostream &logout);
76};
77
78
79// The recptprotoptr function does not 'own' the recptproto. The
80// recptproto should be deleted by the code which created it.
81class recptprotoptr {
82public:
83 recptproto *p;
84
85 recptprotoptr () {p=NULL;}
86};
87
88typedef vector<recptprotoptr> recptprotoptrlist;
89
90
91// contains a list of recptprotos
92class recptprotolistclass {
93protected:
94 recptprotoptrlist recptprotoptrs;
95
96public:
97 // type support for recptprotolistclass
98 typedef recptprotoptrlist::iterator iterator;
99 typedef recptprotoptrlist::const_iterator const_iterator;
100 typedef recptprotoptrlist::reference reference;
101 typedef recptprotoptrlist::const_reference const_reference;
102 typedef recptprotoptrlist::size_type size_type;
103
104 typedef recptprotoptrlist::difference_type difference_type;
105 typedef recptprotoptrlist::const_reverse_iterator const_reverse_iterator;
106 typedef recptprotoptrlist::reverse_iterator reverse_iterator;
107
108 // basic container support
109 iterator begin () {return recptprotoptrs.begin();}
110 const_iterator begin () const {return recptprotoptrs.begin();}
111 iterator end () {return recptprotoptrs.end();}
112 const_iterator end () const {return recptprotoptrs.end();}
113
114 void erase(iterator pos) {recptprotoptrs.erase(pos);}
115 void erase(iterator first, iterator last) {recptprotoptrs.erase(first, last);}
116 recptprotolistclass &operator=(const recptprotolistclass &x)
117 {recptprotoptrs=x.recptprotoptrs;return *this;}
118
119 bool empty () const {return recptprotoptrs.empty();}
120 size_type size() const {return recptprotoptrs.size();}
121
122
123 // added functionality
124 void clear () {recptprotoptrs.erase(recptprotoptrs.begin(),recptprotoptrs.end());}
125
126 // therecptproto remains the property of the calling code but
127 // should not be deleted until it is removed from this list.
128 void addrecptproto (recptproto *therecptproto);
129
130 // getrecptproto will return NULL if a recptproto for the given colelction
131 // could not be found
132 recptproto *getrecptproto (const text_t &collection, ostream &logout);
133};
134
135
136#endif
Note: See TracBrowser for help on using the repository browser.