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