00001 // ******************************************************************* 00002 // Server.h 00003 // ******************************************************************* 00004 // 00005 // DESCRIPTION: contains the function prototypes and the #includes 00006 // used in implementation of the DocConversion Server. 00007 // 00008 // NOTE: This program makes use of the STL string. 00009 // 00010 // CHANGE LOG: 00011 // 2003-10-15 Initial creation. 00012 // 00013 /*************************************************************************** 00014 * Copyright (C) 2003 by drs. Eric D. Schabell * 00015 * erics@cs.kun.nl * 00016 * * 00017 * This program is free software; you can redistribute it and/or modify * 00018 * it under the terms of the GNU General Public License as published by * 00019 * the Free Software Foundation; either version 2 of the License, or * 00020 * (at your option) any later version. * 00021 ***************************************************************************/ 00022 00023 //-------------------------------------------------------------------- 00024 //conditional compilation 00025 //-------------------------------------------------------------------- 00026 #ifndef _SERVER_H 00027 #define _SERVER_H 00028 00029 00030 //-------------------------------------------------------------------- 00031 //#includes 00032 //-------------------------------------------------------------------- 00033 #include <string> 00034 #include "Document.h" 00035 #include <pqxx/all.h> // postgresql api. 00036 00037 using namespace std; 00038 using namespace pqxx; 00039 00040 00041 00042 class Server 00043 { 00044 public: 00045 00046 //-------------------------------------------------------------------- 00047 //Purpose: Default constructor. 00048 //Preconditions: none. 00049 //Postconditions: Server object created. 00050 //Arguments: none. 00051 //Returns: 0. 00052 //Called Funcs: none. 00053 //-------------------------------------------------------------------- 00054 Server(); 00055 00056 //-------------------------------------------------------------------- 00057 //Purpose: Constructo with server address. 00058 //Preconditions: none.. 00059 //Postconditions: Server object created, serverAddress set. 00060 //Arguments: string address. 00061 //Returns: 0. 00062 //Called Funcs: none. 00063 //-------------------------------------------------------------------- 00064 Server( string address ); 00065 00066 //-------------------------------------------------------------------- 00067 //Purpose: Destructor. 00068 //Preconditions: Server object exists.. 00069 //Postconditions: Server object destroyed. 00070 //Arguments: none. 00071 //Returns: 0. 00072 //Called Funcs: none. 00073 //-------------------------------------------------------------------- 00074 ~Server(); 00075 00076 //-------------------------------------------------------------------- 00077 //Purpose: conversion of the provided Document, based 00078 // on the objects registered conversion routine. 00079 //Preconditions: Document object. 00080 //Postconditions: returns true if conversion successfull, false if not. 00081 // Converted document location is registered in the 00082 // Document.conLocation attribute. 00083 //Arguments: Document& doc. 00084 //Returns: bool. 00085 //Called Funcs: Document.getDocumentConversion(), 00086 // Document.getFileLocation(), getFile(), 00087 // Document.getDocumentFile(), 00088 // Document.setFileLocation(), 00089 // Document.getDocumentConversion(), system(), 00090 // c_str(), Document.setConversionLocation(). 00091 //-------------------------------------------------------------------- 00092 bool requestConversion( Document& doc ); 00093 00094 //-------------------------------------------------------------------- 00095 //Purpose: obtain list of conversions in database. 00096 //Preconditions: DB must be available. 00097 //Postconditions: returns Result object contianing the list of available 00098 // conversions. 00099 // This is a 5 column answer: 00100 // routine_name, 00101 // from_feature_type, 00102 // to_feature_type, 00103 // from_representation_type, 00104 // to_representation_type. 00105 //Arguments: none. 00106 //Returns: Result. 00107 //Called Funcs: Connection(), Transaction(), Result(), 00108 // Transaction.Exec(), Transaction.Commit(). 00109 //-------------------------------------------------------------------- 00110 Result listConversionDB(); 00111 00112 //-------------------------------------------------------------------- 00113 //Purpose: obtain list of conversions in database based on 00114 // given representation type. 00115 //Preconditions: DB must be available. 00116 //Postconditions: returns Result object contianing the list of available 00117 // conversions. 00118 // This is a 5 column answer: 00119 // routine_name, 00120 // from_feature_type, 00121 // to_feature_type, 00122 // from_representation_type, 00123 // to_representation_type. 00124 //Arguments: none. 00125 //Returns: Result. 00126 //Called Funcs: Connection(), Transaction(), Result(), 00127 // Transaction.Exec(), Transaction.Commit(). 00128 //-------------------------------------------------------------------- 00129 Result listRepesentationTypes( string representationType ); 00130 00131 00132 //-------------------------------------------------------------------- 00133 //Purpose: obtain list of conversions in database based on 00134 // given feature type. 00135 //Preconditions: DB must be available. 00136 //Postconditions: returns Result object contianing the list of available 00137 // conversions. 00138 // This is a 5 column answer: 00139 // routine_name, 00140 // from_feature_type, 00141 // to_feature_type, 00142 // from_representation_type, 00143 // to_representation_type. 00144 //Arguments: none. 00145 //Returns: Result. 00146 //Called Funcs: Connection(), Transaction(), Result(), 00147 // Transaction.Exec(), Transaction.Commit(). 00148 //-------------------------------------------------------------------- 00149 Result listFeatureTypes( string featureType ); 00150 00151 00152 private: 00153 string serverAddress; // address of server, either dns name or ip. 00154 const string DEFAULT_ADDRESS; // localhost used if notinitialized. 00155 00156 //-------------------------------------------------------------------- 00157 //Purpose: retrieve the Document file from its url location. 00158 //Preconditions: Document object. 00159 //Postconditions: returns true if file retrieval successfull, false if not. 00160 // Only does remote retrieval after checking for local 00161 // presence of the file. The location of the file is set 00162 // for the Document.fileLocation attribute. 00163 //Arguments: Document& doc. 00164 //Returns: bool. 00165 //Called Funcs: Document.getDocumentFile(), ifstream.open(), 00166 // c_str(), system(), Document.getDocumentUrl(), 00167 // Document.setFileLocation(), ifstream.close(). 00168 //-------------------------------------------------------------------- 00169 bool getFile ( Document& doc ); 00170 }; 00171 00172 #endif