Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

Broker.h

Go to the documentation of this file.
00001 // *******************************************************************
00002 // Broker.h
00003 // *******************************************************************
00004 //
00005 //  DESCRIPTION: API for Broker class. Used by clients of the
00006 //                        DocConversion project to broker a conversion
00007 //                        of a given document.
00008 //  NOTE:             This program makes use of strings and Document.h.
00009 //
00010 /***************************************************************************
00011  *   Copyright (C) 2003 by drs. Eric D. Schabell                           *
00012  *   erics@cs.kun.nl                                                       *
00013  *                                                                         *
00014  *   This program is free software; you can redistribute it and/or modify  *
00015  *   it under the terms of the GNU General Public License as published by  *
00016  *   the Free Software Foundation; either version 2 of the License, or     *
00017  *   (at your option) any later version.                                   *
00018  ***************************************************************************/
00019 #ifndef _BROKER_H_
00020 #define _BROKER_H_
00021 
00022 //--------------------------------------------------------------------
00023 //#includes
00024 //--------------------------------------------------------------------
00025 #include <string>           // STL strings.
00026 #include <pqxx/all.h>       // postgresql api.
00027 #include "Document.h"
00028 
00029 using namespace std;
00030 using namespace pqxx;
00031 
00032 
00033 class Broker
00034 {
00035 
00036 public:
00037 
00038     //--------------------------------------------------------------------
00039     //Purpose:           default constructor.
00040     //Preconditions:    none.
00041     //Postconditions:  a Broker object is instantiated.
00042     //Arguments:       none.
00043     //Returns:           Broker.
00044     //Called Funcs:    increaseCounter().
00045     //--------------------------------------------------------------------
00046     Broker ();
00047 
00048     //--------------------------------------------------------------------
00049     //Purpose:            constructor with a (remote) server name given.
00050     //Preconditions:    must supply a valid server hostname.
00051     //Postconditions:  a Broker object is instantiated with a
00052     //                       remote server hostname.
00053     //Arguments:       string name.
00054     //Returns:           Broker.
00055     //Called Funcs:    increaseCounter().
00056     //--------------------------------------------------------------------
00057     Broker ( const string name );
00058 
00059     //--------------------------------------------------------------------
00060     //Purpose:            default destructor.
00061     //Preconditions:    Broker object.
00062     //Postconditions:  Broker object destroyed.
00063     //Arguments:       none.
00064     //Returns:           0
00065     //Called Funcs:    decreaseCounter().
00066     //--------------------------------------------------------------------
00067     ~Broker();
00068 
00069     //--------------------------------------------------------------------
00070     //Purpose:            obtain the Broker Counter's current value.
00071     //Preconditions:    none.
00072     //Postconditions:  returns brokerCounter value.
00073     //Arguments:       none.
00074     //Returns:           const int brokerCounter.
00075     //Called Funcs:    none.
00076     //--------------------------------------------------------------------
00077     const int getCounter();
00078 
00079     //--------------------------------------------------------------------
00080     //Purpose:            obtain the name of the server which the Broker
00081     //                        is brokering with.
00082     //Preconditions:    none.
00083     //Postconditions:  returns serverName.
00084     //Arguments:       none.
00085     //Returns:           const string serverName.
00086     //Called Funcs:    none.
00087     //--------------------------------------------------------------------
00088     const string getServerName();
00089 
00090     //--------------------------------------------------------------------
00091     //Purpose:            prepare for conversion of the provided Document,
00092     //                        and pass to Server for actual converison.
00093     //Preconditions:    Document object.
00094     //Postconditions:  returns true if conversion successfull, false if not.
00095     //                       Converted document location is registered in the
00096     //                       Document.conLocation attribute.
00097     //Arguments:       Document& doc.
00098     //Returns:           bool.
00099     //Called Funcs:   Document.getDocumentConversion(),
00100     //                      getServerName(), Server(),
00101     //                      Server.requestConversion().
00102     //--------------------------------------------------------------------
00103     bool convertDocument ( Document& doc );
00104 
00105     //--------------------------------------------------------------------
00106     //Purpose:          obtain list of conversions in conversion database.
00107     //Preconditions:    Server must be available.
00108     //Postconditions:   returns Result object contianing the list of available
00109     //                        conversions.
00110     //                       This is a 5 column answer:
00111     //                         routine_name,
00112     //                         from_feature_type,
00113     //                         to_feature_type,
00114     //                         from_representation_type,
00115     //                         to_representation_type.
00116     //Arguments:        none.
00117     //Returns:          Result.
00118     //Called Funcs:     Server.listConversionDB().
00119     //--------------------------------------------------------------------
00120     Result getConversionListing();
00121 
00122 
00123     //--------------------------------------------------------------------
00124     //Purpose:          obtain list of available conversions in conversion
00125     //                      database based on given representation type..
00126     //Preconditions:    Server must be available.
00127     //Postconditions:   returns Result object contianing the list of available
00128     //                        conversions.
00129     //                       This is a 5 column answer:
00130     //                         routine_name,
00131     //                         from_feature_type,
00132     //                         to_feature_type,
00133     //                         from_representation_type,
00134     //                         to_representation_type.
00135     //Arguments:        none.
00136     //Returns:          Result.
00137     //Called Funcs:     Broker(), Server.listRepresentaionTypes( string representationType ).
00138     //--------------------------------------------------------------------
00139     Result getRepresentationTypeListing( string representationType );
00140 
00141     //--------------------------------------------------------------------
00142     //Purpose:          obtain list of available conversions in conversion
00143     //                      database based on given feature type..
00144     //Preconditions:    Server must be available.
00145     //Postconditions:   returns Result object contianing the list of available
00146     //                        conversions.
00147     //                       This is a 5 column answer:
00148     //                         routine_name,
00149     //                         from_feature_type,
00150     //                         to_feature_type,
00151     //                         from_representation_type,
00152     //                         to_representation_type.
00153     //Arguments:        none.
00154     //Returns:          Result.
00155     //Called Funcs:     Broker(), Server.listFeatureTypes( string featureType ).
00156     //--------------------------------------------------------------------
00157     Result getFeatureTypeListing( string featureType );
00158 
00159 
00160 
00161 private:
00162     static int brokerCounter;   // keeps track of  nr. activerokers.
00163     static const string DEFAULT_NAME;  // localhost used if notinitialized.
00164     string serverName;          // name of conversion server..
00165 
00166     //--------------------------------------------------------------------
00167     //Purpose:            to increase the brokerCounter attribute.
00168     //Preconditions:    none.
00169     //Postconditions:  brokerCounter attribute has increased by one.
00170     //Arguments:       none.
00171     //Returns:           0.
00172     //Called Funcs:    none.
00173     //--------------------------------------------------------------------
00174     void increaseCounter();
00175 
00176     //--------------------------------------------------------------------
00177     //Purpose:            to decrease the brokerCounter attribute.
00178     //Preconditions:    none.
00179     //Postconditions:  brokerCounter attribute has decreased by one.
00180     //Arguments:       none.
00181     //Returns:           0.
00182     //Called Funcs:    none.
00183     //--------------------------------------------------------------------
00184     void decreaseCounter();
00185 };
00186 
00187 #endif /* _BROKER_H_ */

Generated on Thu Dec 4 14:39:17 2003 for docconversion.kdevelop by doxygen 1.3.4