00001 /* $Id: OSCommandLine.cpp 4340 2011-10-15 20:08:33Z Gassmann $ */ 00021 #include <cstdio> 00022 #include <sstream> 00023 00024 #include "OSConfig.h" 00025 #include "OSInstance.h" 00026 #include "OSOption.h" 00027 #include "OSOutput.h" 00028 #include "OSCommandLine.h" 00029 00030 using std::string; 00031 00032 extern const OSSmartPtr<OSOutput> osoutput; 00033 00034 void OSCommandLine::reset_options() 00035 { 00036 #ifndef NDEBUG 00037 osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_trace, "Reset command line options\n"); 00038 #endif 00039 if (osinstance != NULL) delete osinstance; 00040 osinstance = NULL; 00041 if (osoption != NULL) delete osoption; 00042 osoption = NULL; 00043 serviceLocation = ""; 00044 serviceMethod = ""; 00045 solverName = ""; 00046 configFile = ""; 00047 osilFile = ""; 00048 osil = ""; 00049 osilOutputFile = ""; 00050 osolFile = ""; 00051 osol = ""; 00052 osolOutputFile = ""; 00053 osrlFile = ""; 00054 insListFile = ""; 00055 insList = ""; 00056 osplInputFile = ""; 00057 osplInput = ""; 00058 osplOutputFile = ""; 00059 mpsFile = ""; 00060 mps = ""; 00061 nlFile = ""; 00062 nl = ""; 00063 datFile = ""; 00064 dat = ""; 00065 gamsControlFile = ""; 00066 browser = ""; 00067 printLevel = DEFAULT_OUTPUT_LEVEL; 00068 logFile = ""; 00069 filePrintLevel = DEFAULT_OUTPUT_LEVEL; 00070 jobID = ""; 00071 invokeHelp = false; 00072 listOptions = false; 00073 writeVersion = false; 00074 printModel = false; 00075 printRowNumberAsString = ""; 00076 quit = false; 00077 #ifndef NDEBUG 00078 osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_trace, "Done resetting command line options\n"); 00079 #endif 00080 }// reset_options 00081 00082 OSCommandLine::OSCommandLine(): 00083 osinstance(NULL), 00084 osoption(NULL) 00085 { 00086 #ifndef NDEBUG 00087 osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_trace, "Inside command line constructor\n"); 00088 #endif 00089 reset_options(); 00090 } 00091 00092 OSCommandLine::~OSCommandLine() 00093 { 00094 #ifndef NDEBUG 00095 osoutput->OSPrint(ENUM_OUTPUT_AREA_main, ENUM_OUTPUT_LEVEL_trace, "Inside command line destructor\n"); 00096 #endif 00097 if (osinstance != NULL) delete osinstance; 00098 osinstance = NULL; 00099 if (osoption != NULL) delete osoption; 00100 osoption = NULL; 00101 } 00102 00103 void OSCommandLine::convertSolverNameToLowerCase() 00104 { 00105 unsigned int k; 00106 for (k = 0; k < solverName.length(); k++) 00107 { 00108 solverName[k] = (char)tolower(solverName[k]); 00109 } 00110 } 00111 00112 void OSCommandLine::convertSolverNameToUpperCase() 00113 { 00114 unsigned int k; 00115 for (k = 0; k < solverName.length(); k++) 00116 { 00117 solverName[k] = (char)toupper(solverName[k]); 00118 } 00119 } 00120 00121 std::string OSCommandLine::list_options() 00122 { 00123 std::ostringstream outStr; 00124 outStr << "The following command line options and values have been read:" 00125 << std::endl; 00126 if (serviceLocation != "") 00127 outStr << "Service Location = " 00128 << serviceLocation 00129 << std::endl; 00130 if (serviceMethod != "") 00131 outStr << "Service Method = " 00132 << serviceMethod 00133 << std::endl; 00134 if ( solverName != "") 00135 outStr << "Selected Solver = " 00136 << solverName 00137 << std::endl; 00138 00139 if (configFile != "") 00140 outStr << "Config file = " 00141 << configFile 00142 << std::endl; 00143 if (osilFile != "") 00144 outStr << "OSiL file = " 00145 << osilFile 00146 << std::endl; 00147 if (osilOutputFile != "") 00148 outStr << "OSiL output file = " 00149 << osilOutputFile 00150 << std::endl; 00151 if (osolFile != "") 00152 outStr << "OSoL file = " 00153 << osolFile 00154 << std::endl; 00155 if (osolOutputFile != "") 00156 outStr << "OSoL output file = " 00157 << osolOutputFile 00158 << std::endl; 00159 if (osrlFile != "") 00160 outStr << "OSrL file = " 00161 << osrlFile 00162 << std::endl; 00163 if (insListFile != "") 00164 outStr << "Instruction List file = " 00165 << insListFile 00166 << std::endl; 00167 if (osplInputFile != "") 00168 outStr << "OSpL Input file = " 00169 << osplInputFile 00170 << std::endl; 00171 if (osplOutputFile != "") 00172 outStr << "OSpL Output file = " 00173 << osplOutputFile 00174 << std::endl; 00175 if (mpsFile != "") 00176 outStr << "MPS File Name = " 00177 << mpsFile 00178 << std::endl; 00179 if (nlFile != "") 00180 outStr << "NL File Name = " 00181 << nlFile 00182 << std::endl; 00183 if (datFile != "") 00184 outStr << "GAMS dat file = " 00185 << mpsFile 00186 << std::endl; 00187 if (gamsControlFile != "") 00188 outStr << "GAMS control file = " 00189 << gamsControlFile 00190 << std::endl; 00191 00192 if (browser != "") 00193 outStr << "Result browser = " 00194 << browser 00195 << std::endl; 00196 outStr << "Print level for stdout: " 00197 << printLevel 00198 << std::endl; 00199 00200 if (logFile != "") 00201 outStr << "Secondary log to " 00202 << logFile 00203 << std::endl; 00204 outStr << "Print level for " << logFile << ": " 00205 << printLevel 00206 << std::endl; 00207 00208 if (jobID != "") 00209 outStr << "job ID = " 00210 << jobID 00211 << std::endl; 00212 00213 if (printModel) 00214 outStr << "Print model = true" 00215 << std::endl; 00216 if (printRowNumberAsString != "") 00217 outStr << "Print row " 00218 << printRowNumberAsString 00219 << std::endl; 00220 return outStr.str(); 00221 }// list_options
1.6.1