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 "OSCommandLine.h" 00025 #include <stdio.h> 00026 00027 //#define DEBUG_COMMANDLINE 00028 00029 00030 void OSCommandLine::reset_options() 00031 { 00032 if (osinstance != NULL) delete osinstance; 00033 osinstance = NULL; 00034 if (osoption != NULL) delete osoption; 00035 osoption = NULL; 00036 osinstance = NULL; 00037 osoption = NULL; 00038 serviceLocation = ""; 00039 serviceMethod = ""; 00040 solverName = ""; 00041 configFile = ""; 00042 osilFile = ""; 00043 osilOutputFile = ""; 00044 osil = ""; 00045 osolFile = ""; 00046 osol = ""; 00047 osrlFile = ""; 00048 insListFile = ""; 00049 insList = ""; 00050 osplInputFile = ""; 00051 osplInput = ""; 00052 osplOutputFile = ""; 00053 mpsFile = ""; 00054 mps = ""; 00055 nlFile = ""; 00056 nl = ""; 00057 datFile = ""; 00058 dat = ""; 00059 gamsControlFile = ""; 00060 browser = ""; 00061 invokeHelp = false; 00062 listOptions = false; 00063 writeVersion = false; 00064 printModel = false; 00065 printRowNumberAsString = ""; 00066 quit = false; 00067 }// reset_options 00068 00069 OSCommandLine::OSCommandLine(): 00070 osinstance(NULL), 00071 osoption(NULL) 00072 { 00073 #ifdef DEBUG_COMMANDLINE 00074 std::cout << "Inside command line constructor" << std::endl; 00075 #endif 00076 reset_options(); 00077 } 00078 00079 OSCommandLine::~OSCommandLine() 00080 { 00081 #ifdef DEBUG_COMMANDLINE 00082 std::cout << "Inside command line destructor" << std::endl; 00083 #endif 00084 if (osinstance != NULL) delete osinstance; 00085 osinstance = NULL; 00086 if (osoption != NULL) delete osoption; 00087 osoption = NULL; 00088 } 00089 00090 void OSCommandLine::convertSolverNametoLowerCase() 00091 { 00092 unsigned int k; 00093 for (k = 0; k < solverName.length(); k++) 00094 { 00095 solverName[k] = (char)tolower(solverName[k]); 00096 } 00097 } 00098 00099 void OSCommandLine::convertSolverNametoUpperCase() 00100 { 00101 unsigned int k; 00102 for (k = 0; k < solverName.length(); k++) 00103 { 00104 solverName[k] = (char)toupper(solverName[k]); 00105 } 00106 } 00107 00108 std::string OSCommandLine::list_options() 00109 { 00110 std::ostringstream outStr; 00111 outStr 00112 << "The following command line options and values have been read:" 00113 << std::endl; 00114 if (serviceLocation != "") 00115 outStr << "Service Location = " 00116 << serviceLocation 00117 << std::endl; 00118 if (serviceMethod != "") 00119 outStr << "Service Method = " 00120 << serviceMethod 00121 << std::endl; 00122 if ( solverName != "") 00123 outStr << "Selected Solver = " 00124 << solverName 00125 << std::endl; 00126 00127 if (configFile != "") 00128 outStr << "Config file = " 00129 << configFile 00130 << std::endl; 00131 if (osilFile != "") 00132 outStr << "OSiL file = " 00133 << osilFile 00134 << std::endl; 00135 if (osilOutputFile != "") 00136 outStr << "OSiL output file = " 00137 << osilOutputFile 00138 << std::endl; 00139 if (osolFile != "") 00140 outStr << "OSoL file = " 00141 << osolFile 00142 << std::endl; 00143 if (osrlFile != "") 00144 outStr << "OSrL file = " 00145 << osrlFile 00146 << std::endl; 00147 if (insListFile != "") 00148 outStr << "Instruction List file = " 00149 << insListFile 00150 << std::endl; 00151 if (osplInputFile != "") 00152 outStr << "OSpL Input file = " 00153 << osplInputFile 00154 << std::endl; 00155 if (osplOutputFile != "") 00156 outStr << "OSpL Output file = " 00157 << osplOutputFile 00158 << std::endl; 00159 if (mpsFile != "") 00160 outStr << "MPS File Name = " 00161 << mpsFile 00162 << std::endl; 00163 if (nlFile != "") 00164 outStr << "NL File Name = " 00165 << nlFile 00166 << std::endl; 00167 if (datFile != "") 00168 outStr << "GAMS dat file = " 00169 << mpsFile 00170 << std::endl; 00171 if (gamsControlFile != "") 00172 outStr << "GAMS control file = " 00173 << gamsControlFile 00174 << std::endl; 00175 00176 if (browser != "") 00177 outStr << "Result browser = " 00178 << browser 00179 << std::endl; 00180 00181 if (printModel) 00182 outStr << "Print model = true" 00183 << std::endl; 00184 if (printRowNumberAsString != "") 00185 outStr << "Print row " 00186 << printRowNumberAsString 00187 << std::endl; 00188 return outStr.str(); 00189 }// list_options