/********************************************************************** * * recptproto.cpp -- * Copyright (C) 1999 The New Zealand Digital Library Project * * A component of the Greenstone digital library software * from the New Zealand Digital Library Project at the * University of Waikato, New Zealand. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: recptproto.cpp 533 1999-09-07 04:57:01Z sjboddie $ * *********************************************************************/ /* $Log$ Revision 1.7 1999/09/07 04:56:59 sjboddie added GPL notice Revision 1.6 1999/05/10 03:40:43 sjboddie lots of changes - slowly getting document action sorted out Revision 1.5 1999/04/30 01:59:43 sjboddie lots of stuff - getting documentaction working (documentaction replaces old browseaction) Revision 1.4 1999/03/31 23:44:48 rjmcnab Altered the protocol so that the metadata is part of the filter. Revision 1.3 1999/03/03 23:26:35 sjboddie Implemented more of the protocol Revision 1.2 1999/02/25 21:59:01 rjmcnab Merged sources. Revision 1.1 1999/02/21 22:35:24 rjmcnab Initial revision. */ #include "recptproto.h" #include // configure should be called for each line in the configuration file void recptproto::configure (const text_t &/*key*/, const text_tarray &/*cfgline*/) { } // init should be called after the configuration but before any other // functions are called. If init returns false a message will be written // out to the log file and no other output should be produced. bool recptproto::init (ostream &/*logout*/) { return true; } // get_protocol_name should return the name of this protocol (e.g. recptproto) // that can be used to do run time type identification and display information // about the protocol. text_t recptproto::get_protocol_name () { return "recptproto"; } // get_collection_list returns the list of collections that // this protocol knows about void recptproto::get_collection_list (text_tarray &collist, comerror_t &err, ostream &/*logout*/) { collist.erase(collist.begin(),collist.end()); err = noError; } // has_collection sets 'hascollection' to be true if the protocol // can communicate with the collection (i.e. it is within its // collection list). This function should be implemented in as // efficient time as possible as it will be called for each page // access and for each protocol. void recptproto::has_collection (const text_t &/*collection*/, bool &hascollection, comerror_t &err, ostream &/*logout*/) { hascollection = false; err = noError; } // sets 'wassuccess' to be true if a successful ping was done to // the given collection. void recptproto::ping (const text_t &/*collection*/, bool &wassuccess, comerror_t &err, ostream &/*logout*/) { wassuccess = false; // no collections are supported by this class err = noError; } // obtains general information about the collection void recptproto::get_collectinfo (const text_t &/*collection*/, ColInfoResponse_t &/*collectinfo*/, comerror_t &err, ostream &/*logout*/) { err = protocolError; } // gets a list of all the filters void recptproto::get_filterinfo (const text_t &/*collection*/, InfoFiltersResponse_t &/*reponse*/, comerror_t &err, ostream &/*logout*/) { err = protocolError; } // gets all the filter options for a particular filter void recptproto::get_filteroptions (const text_t &/*collection*/, const InfoFilterOptionsRequest_t &/*request*/, InfoFilterOptionsResponse_t &/*response*/, comerror_t &err, ostream &/*logout*/) { err = protocolError; } // filters (search or browse) a result set void recptproto::filter (const text_t &/*collection*/, FilterRequest_t &/*request*/, FilterResponse_t &/*response*/, comerror_t &err, ostream &/*logout*/) { err = protocolError; } void recptproto::get_document (const text_t &/*collection*/, const DocumentRequest_t &/*request*/, DocumentResponse_t &/*response*/, comerror_t &err, ostream &/*logout*/) { err = protocolError; } // therecptproto remains the property of the calling code but // should not be deleted until it is removed from this list. void recptprotolistclass::addrecptproto (recptproto *therecptproto) { // can't add a protocol that doesn't exist assert (therecptproto != NULL); if (therecptproto == NULL) return; recptprotoptr rpp; rpp.p = therecptproto; recptprotoptrs.push_back(rpp); } // getrecptproto will return NULL if a recptproto for the given colelction // could not be found recptproto *recptprotolistclass::getrecptproto (const text_t &collection, ostream &logout) { iterator here = recptprotoptrs.begin (); iterator end = recptprotoptrs.end (); bool hascollection; comerror_t err; while (here != end) { assert ((*here).p != NULL); if ((*here).p != NULL) { (*here).p->has_collection (collection, hascollection, err, logout); if ((err == noError) && (hascollection == true)) return (*here).p; } here++; } return NULL; }