From: secher Date: Thu, 29 May 2008 12:15:25 +0000 (+0000) Subject: first version of launching executable from xml file X-Git-Tag: afterMerge_V4_1_3rc1~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f338c146dcce3ef5dac1cf2afc7c16ccb64d4428;p=modules%2Fkernel.git first version of launching executable from xml file --- diff --git a/idl/SALOME_ContainerManager.idl b/idl/SALOME_ContainerManager.idl index 515e939ea..7faca1ae6 100644 --- a/idl/SALOME_ContainerManager.idl +++ b/idl/SALOME_ContainerManager.idl @@ -89,6 +89,8 @@ struct BatchParameters */ interface SalomeLauncher { + long submitJob( in string xmlExecuteFile, + in string clusterName ) raises (SALOME::SALOME_Exception); long submitSalomeJob( in string fileToExecute, in FilesList filesToExport, in FilesList filesToImport, diff --git a/src/Batch/Batch_BatchManager_eClient.cxx b/src/Batch/Batch_BatchManager_eClient.cxx index 41ce47c2e..d0b76fe9b 100644 --- a/src/Batch/Batch_BatchManager_eClient.cxx +++ b/src/Batch/Batch_BatchManager_eClient.cxx @@ -89,24 +89,27 @@ namespace Batch { // Second step : copy fileToExecute into // batch tmp files directory - command = copy_command; - command += string(params[EXECUTABLE]); - command += " "; - if(_username != ""){ - command += _username; - command += "@"; - } - command += _hostname; - command += ":"; - command += string(params[TMPDIR]); - cerr << command.c_str() << endl; - status = system(command.c_str()); - if(status) { - std::ostringstream oss; - oss << status; - std::string ex_mess("Error of connection on remote host ! status = "); - ex_mess += oss.str(); - throw EmulationException(ex_mess.c_str()); + string executeFile = params[EXECUTABLE]; + if( executeFile.size() > 0 ){ + command = copy_command; + command += string(params[EXECUTABLE]); + command += " "; + if(_username != ""){ + command += _username; + command += "@"; + } + command += _hostname; + command += ":"; + command += string(params[TMPDIR]); + cerr << command.c_str() << endl; + status = system(command.c_str()); + if(status) { + std::ostringstream oss; + oss << status; + std::string ex_mess("Error of connection on remote host ! status = "); + ex_mess += oss.str(); + throw EmulationException(ex_mess.c_str()); + } } // Third step : copy filesToExportList into diff --git a/src/Batch/Batch_BatchManager_eLSF.cxx b/src/Batch/Batch_BatchManager_eLSF.cxx index d1c44e60d..15eb740a3 100644 --- a/src/Batch/Batch_BatchManager_eLSF.cxx +++ b/src/Batch/Batch_BatchManager_eLSF.cxx @@ -53,9 +53,14 @@ namespace Batch { Parametre params = job.getParametre(); const std::string dirForTmpFiles = params[TMPDIR]; const string fileToExecute = params[EXECUTABLE]; - string::size_type p1 = fileToExecute.find_last_of("/"); - string::size_type p2 = fileToExecute.find_last_of("."); - std::string fileNameToExecute = fileToExecute.substr(p1+1,p2-p1-1); + std::string fileNameToExecute; + if( fileToExecute.size() > 0 ){ + string::size_type p1 = fileToExecute.find_last_of("/"); + string::size_type p2 = fileToExecute.find_last_of("."); + fileNameToExecute = fileToExecute.substr(p1+1,p2-p1-1); + } + else + fileNameToExecute = "command"; // export input files on cluster exportInputFiles(job); @@ -230,19 +235,28 @@ namespace Batch { { int status; Parametre params = job.getParametre(); + Environnement env = job.getEnvironnement(); const int nbproc = params[NBPROC]; const long edt = params[MAXWALLTIME]; const long mem = params[MAXRAMSIZE]; const string workDir = params[WORKDIR]; const std::string dirForTmpFiles = params[TMPDIR]; const string fileToExecute = params[EXECUTABLE]; - string::size_type p1 = fileToExecute.find_last_of("/"); - string::size_type p2 = fileToExecute.find_last_of("."); - std::string rootNameToExecute = fileToExecute.substr(p1+1,p2-p1-1); - std::string fileNameToExecute = "~/" + dirForTmpFiles + "/" + string(basename(fileToExecute.c_str())); - - int idx = dirForTmpFiles.find("Batch/"); - std::string filelogtemp = dirForTmpFiles.substr(idx+6, dirForTmpFiles.length()); + std::string rootNameToExecute; + std::string fileNameToExecute; + std::string filelogtemp; + if( fileToExecute.size() > 0 ){ + string::size_type p1 = fileToExecute.find_last_of("/"); + string::size_type p2 = fileToExecute.find_last_of("."); + rootNameToExecute = fileToExecute.substr(p1+1,p2-p1-1); + fileNameToExecute = "~/" + dirForTmpFiles + "/" + string(basename(fileToExecute.c_str())); + + int idx = dirForTmpFiles.find("Batch/"); + filelogtemp = dirForTmpFiles.substr(idx+6, dirForTmpFiles.length()); + } + else{ + rootNameToExecute = "command"; + } std::string TmpFileName = BuildTemporaryFileName(); ofstream tempOutputFile; @@ -254,13 +268,26 @@ namespace Batch { if( mem > 0 ) tempOutputFile << "#BSUB -M " << mem*1024 << endl ; tempOutputFile << "#BSUB -n " << nbproc << endl ; - tempOutputFile << "#BSUB -o runSalome.output.log." << filelogtemp << endl ; - tempOutputFile << "#BSUB -e runSalome.error.log." << filelogtemp << endl ; + if( fileToExecute.size() > 0 ){ + tempOutputFile << "#BSUB -o output.log." << filelogtemp << endl ; + tempOutputFile << "#BSUB -e error.log." << filelogtemp << endl ; + } + else{ + tempOutputFile << "#BSUB -o " << env["LOGFILE"] << ".output.log" << endl ; + tempOutputFile << "#BSUB -e " << env["LOGFILE"] << ".error.log" << endl ; + } if( workDir.size() > 0 ) tempOutputFile << "cd " << workDir << endl ; - tempOutputFile << _mpiImpl->boot("",nbproc); - tempOutputFile << _mpiImpl->run("",nbproc,fileNameToExecute); - tempOutputFile << _mpiImpl->halt(); + if( fileToExecute.size() > 0 ){ + tempOutputFile << _mpiImpl->boot("",nbproc); + tempOutputFile << _mpiImpl->run("",nbproc,fileNameToExecute); + tempOutputFile << _mpiImpl->halt(); + } + else{ + tempOutputFile << "source " << env["SOURCEFILE"] << endl ; + tempOutputFile << env["COMMAND"]; + } + tempOutputFile.flush(); tempOutputFile.close(); chmod(TmpFileName.c_str(), 0x1ED); diff --git a/src/Launcher/Launcher.cxx b/src/Launcher/Launcher.cxx index 1bf8d1639..302541e32 100644 --- a/src/Launcher/Launcher.cxx +++ b/src/Launcher/Launcher.cxx @@ -20,6 +20,7 @@ #include "Batch_Date.hxx" #include "Batch_FactBatchManager_eLSF.hxx" #include "Batch_FactBatchManager_ePBS.hxx" +#include "SALOME_Launcher_Handler.hxx" #include "Launcher.hxx" #include #include @@ -58,6 +59,106 @@ Launcher_cpp::~Launcher_cpp() delete it2->second; } +//============================================================================= +/*! CORBA Method: + * Submit a batch job on a cluster and returns the JobId + * \param xmlExecuteFile : to define the execution on the batch cluster + * \param clusterName : name of the batch cluster + */ +//============================================================================= +long Launcher_cpp::submitJob( const std::string xmlExecuteFile, + const std::string clusterName) throw(LauncherException) +{ + cerr << "BEGIN OF Launcher_cpp::submitJob" << endl; + long jobId; + vector aMachineList; + + // verify if cluster is in resources catalog + machineParams params; + params.hostname = clusterName; + vector aCompoList ; + try{ + aMachineList = _ResManager->GetFittingResources(params, aCompoList); + } + catch(const ResourcesException &ex){ + throw LauncherException(ex.msg.c_str()); + } + if (aMachineList.size() == 0) + throw LauncherException("This cluster is not in resources catalog"); + + // Parsing xml file + ParseXmlFile(xmlExecuteFile); + + // verify if clustername is in xml file + map::const_iterator it1 = _launch.MachinesList.find(clusterName); + if(it1 == _launch.MachinesList.end()) + throw LauncherException("This cluster is not in xml file"); + + ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]); + string cname(p.Alias); + cerr << "Choose cluster: " << cname << endl; + + // search batch manager for that cluster in map or instanciate one + map < string, Batch::BatchManager_eClient * >::const_iterator it2 = _batchmap.find(cname); + if(it2 == _batchmap.end()) + { + _batchmap[cname] = FactoryBatchManager(p); + // TODO: Add a test for the cluster ! + } + + try{ + + // directory on cluster to put files to execute + string remotedir = _launch.MachinesList[clusterName].WorkDirectory; + // local directory to get files to execute and to put results + string localdir = _launch.RefDirectory; + + int idx1 = xmlExecuteFile.find_last_of("/"); + if(idx1 == string::npos) idx1 = -1; + int idx2 = xmlExecuteFile.find(".xml"); + string logfile = xmlExecuteFile.substr(idx1+1,idx2-idx1-1); + string ologfile = logfile + ".output.log"; + string elogfile = logfile + ".error.log"; + + // create and submit job on cluster + Batch::Parametre param; + param[USER] = p.UserName; + param[EXECUTABLE] = ""; + for(int i=0; i<_launch.InputFile.size();i++) + param[INFILE] += Batch::Couple( localdir + "/" + _launch.InputFile[i], remotedir + "/" + _launch.InputFile[i] ); + for(int i=0; i<_launch.OutputFile.size();i++) + param[OUTFILE] += Batch::Couple( localdir + "/" + _launch.OutputFile[i], remotedir + "/" + _launch.OutputFile[i] ); + param[OUTFILE] += Batch::Couple( localdir + "/" + ologfile, remotedir + "/" + ologfile ); + param[OUTFILE] += Batch::Couple( localdir + "/" + elogfile, remotedir + "/" + elogfile ); + param[NBPROC] = _launch.NbOfProcesses; + param[WORKDIR] = remotedir; + param[TMPDIR] = remotedir; + param[MAXWALLTIME] = getWallTime(""); + param[MAXRAMSIZE] = getRamSize(""); + + Batch::Environnement env; + env["COMMAND"] = _launch.Command; + env["SOURCEFILE"] = _launch.MachinesList[clusterName].EnvFile; + env["LOGFILE"] = logfile; + + Batch::Job* job = new Batch::Job(param,env); + + // submit job on cluster + Batch::JobId jid = _batchmap[cname]->submitJob(*job); + + // get job id in long + istringstream iss(jid.getReference()); + iss >> jobId; + + _jobmap[ pair(cname,jobId) ] = job; + } + catch(const Batch::EmulationException &ex){ + throw LauncherException(ex.msg.c_str()); + } + + return jobId; +} + //============================================================================= /*! CORBA Method: * Submit a batch job on a cluster and returns the JobId @@ -579,3 +680,31 @@ long Launcher_cpp::getRamSize(std::string mem) else return 0; } + +void Launcher_cpp::ParseXmlFile(string xmlExecuteFile) +{ + SALOME_Launcher_Handler* handler = new SALOME_Launcher_Handler(_launch); + + const char* aFilePath = xmlExecuteFile.c_str(); + FILE* aFile = fopen(aFilePath, "r"); + + if (aFile != NULL) + { + xmlDocPtr aDoc = xmlReadFile(aFilePath, NULL, 0); + + if (aDoc != NULL) + handler->ProcessXmlDocument(aDoc); + else + cerr << "ResourcesManager_cpp: could not parse file "<< aFilePath << endl; + + // Free the document + xmlFreeDoc(aDoc); + + fclose(aFile); + } + else + cerr << "Launcher_cpp: file "< @@ -47,6 +48,9 @@ public: Launcher_cpp(); ~Launcher_cpp(); + long submitJob(const std::string xmlExecuteFile, + const std::string clusterName) throw(LauncherException); + long submitSalomeJob(const std::string fileToExecute , const std::vector& filesToExport , const std::vector& filesToImport , @@ -73,6 +77,11 @@ protected: bool check(const batchParams& batch_params); long getWallTime(std::string edt); long getRamSize(std::string mem); + void ParseXmlFile(std::string xmlExecuteFile); + + //! will contain the informations on the data type catalog(after parsing) + ParserLauncherType _launch; + }; #endif diff --git a/src/Launcher/Makefile.am b/src/Launcher/Makefile.am index e6996d932..bd61a22d8 100644 --- a/src/Launcher/Makefile.am +++ b/src/Launcher/Makefile.am @@ -36,6 +36,8 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am # # header files salomeinclude_HEADERS = \ + SALOME_Launcher_Parser.hxx \ + SALOME_Launcher_Handler.hxx \ SALOME_Launcher.hxx \ Launcher.hxx @@ -106,6 +108,8 @@ libSalomeLauncher_la_LIBADD =\ $(COMMON_LIBS) libLauncher.la libLauncher_la_SOURCES=\ + SALOME_Launcher_Parser.cxx \ + SALOME_Launcher_Handler.cxx \ Launcher.cxx libLauncher_la_CPPFLAGS =\ diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index f051cb32c..5178c9ac4 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -100,6 +100,28 @@ CORBA::Long SALOME_Launcher::getPID() return (CORBA::Long)getpid(); } +//============================================================================= +/*! CORBA Method: + * Submit a batch job on a cluster and returns the JobId + * \param xmlExecuteFile : .xml to parse to execute on the batch cluster + * \param clusterName : cluster name + */ +//============================================================================= +CORBA::Long SALOME_Launcher::submitJob(const char * xmlExecuteFile, + const char * clusterName) +{ + CORBA::Long jobId; + + try{ + jobId = _l.submitJob(xmlExecuteFile,clusterName); + } + catch(const LauncherException &ex){ + INFOS(ex.msg.c_str()); + THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR); + } + return jobId; +} + //============================================================================= /*! CORBA Method: * Submit a batch job on a cluster and returns the JobId diff --git a/src/Launcher/SALOME_Launcher.hxx b/src/Launcher/SALOME_Launcher.hxx index 350fa03d2..7f17b3a6f 100644 --- a/src/Launcher/SALOME_Launcher.hxx +++ b/src/Launcher/SALOME_Launcher.hxx @@ -52,6 +52,9 @@ public: SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa); ~SALOME_Launcher(); + CORBA::Long submitJob(const char * xmlExecuteFile, + const char * clusterName); + CORBA::Long submitSalomeJob(const char * fileToExecute , const Engines::FilesList& filesToExport , const Engines::FilesList& filesToImport , diff --git a/src/Launcher/SALOME_Launcher_Handler.cxx b/src/Launcher/SALOME_Launcher_Handler.cxx new file mode 100755 index 000000000..3b21622e1 --- /dev/null +++ b/src/Launcher/SALOME_Launcher_Handler.cxx @@ -0,0 +1,168 @@ +// SALOME ResourcesCatalog : implementation of catalog resources parsing (SALOME_ModuleCatalog.idl) +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : SALOME_Laucher_Handler.cxx +// Author : Bernard Secher +// Module : SALOME +//$Header$ + +#include "SALOME_Launcher_Handler.hxx" +#include +#include + +using namespace std; + +#ifdef _DEBUG_ +static int MYDEBUG = 1; +#else +static int MYDEBUG = 0; +#endif + +//============================================================================= +/*! + * Constructor + * \param listOfResources: map of ParserResourcesType to fill when parsing + */ +//============================================================================= + +SALOME_Launcher_Handler::SALOME_Launcher_Handler(ParserLauncherType& launch): + _launch(launch) +{ + //XML tags initialisation + test_machine_list = "machine-list"; + test_main = "main"; + + test_machine = "machine"; + test_env_file = "env-file"; + test_work_directory = "work-directory"; + test_ref_directory = "ref-directory"; + test_nb_processes = "nb-processes"; + test_input_file = "input-file"; + test_output_file = "output-file"; + test_command = "command"; + +} + +//============================================================================= +/*! + * Destructor + */ +//============================================================================= + +SALOME_Launcher_Handler::~SALOME_Launcher_Handler() +{ + // cout << "SALOME_Launcher_Handler destruction") << endl; +} + +//============================================================================= +/*! + * Retrieves DS after the file parse. + */ +//============================================================================= + +const ParserLauncherType& +SALOME_Launcher_Handler::GetLauncherAfterParsing() const +{ + return _launch; +} + +//============================================================================= +/*! + * Processes XML document and fills the list of resources + */ +//============================================================================= + +void SALOME_Launcher_Handler::ProcessXmlDocument(xmlDocPtr theDoc) +{ +// if (MYDEBUG) cout << "Begin parse document" << endl; + + // Empty private elements + _launch.Clear(); + + // Get the document root node + xmlNodePtr aCurNode = xmlDocGetRootElement(theDoc); + + aCurNode = aCurNode->xmlChildrenNode; + + // Processing the document nodes + while(aCurNode != NULL){ + if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_machine_list) ){ + xmlNodePtr aCurNode2 = aCurNode->xmlChildrenNode; + while(aCurNode2 != NULL){ + if ( !xmlStrcmp(aCurNode2->name,(const xmlChar*)test_machine) ){ + _machp.Clear(); + xmlChar* name = xmlNodeGetContent(aCurNode2); + string clusterName = (const char*)name; + xmlFree(name); + + if (xmlHasProp(aCurNode2, (const xmlChar*)test_env_file)){ + xmlChar* envfile = xmlGetProp(aCurNode2, (const xmlChar*)test_env_file); + _machp.EnvFile = (const char*)envfile; + xmlFree(envfile); + } + + if (xmlHasProp(aCurNode2, (const xmlChar*)test_work_directory)){ + xmlChar* workdirectory = xmlGetProp(aCurNode2, (const xmlChar*)test_work_directory); + _machp.WorkDirectory = (const char*)workdirectory; + xmlFree(workdirectory); + } + _launch.MachinesList[clusterName]=_machp ; + } + aCurNode2 = aCurNode2->next; + } + } + + if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_ref_directory) ){ + xmlChar* refdirectory = xmlNodeGetContent(aCurNode); + _launch.RefDirectory = (const char*)refdirectory; + xmlFree(refdirectory); + } + + if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_nb_processes) ){ + xmlChar* nbofprocesses = xmlNodeGetContent(aCurNode); + _launch.NbOfProcesses = atoi((const char*)nbofprocesses); + xmlFree(nbofprocesses); + } + + if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_input_file) ){ + xmlChar* inputfile = xmlNodeGetContent(aCurNode); + _launch.InputFile.push_back((const char*)inputfile); + xmlFree(inputfile); + } + + if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_output_file) ){ + xmlChar* outputfile = xmlNodeGetContent(aCurNode); + _launch.OutputFile.push_back((const char*)outputfile); + xmlFree(outputfile); + } + + if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_command) ){ + xmlChar* command = xmlNodeGetContent(aCurNode); + _launch.Command = (const char*)command; + xmlFree(command); + } + + aCurNode = aCurNode->next; + } + +} diff --git a/src/Launcher/SALOME_Launcher_Handler.hxx b/src/Launcher/SALOME_Launcher_Handler.hxx new file mode 100755 index 000000000..e58495854 --- /dev/null +++ b/src/Launcher/SALOME_Launcher_Handler.hxx @@ -0,0 +1,69 @@ +// SALOME ResourcesCatalog : implementation of catalog resources parsing (SALOME_ModuleCatalog.idl) +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : SALOME_Launcher_Handler.hxx +// Author : Bernard SECHER +// Module : SALOME +//$Header$ + +#ifndef SALOME_LAUNCHER_HANDLER +#define SALOME_LAUNCHER_HANDLER + +#include "SALOME_Launcher_Parser.hxx" + +#include +#include + +#include + +class SALOME_Launcher_Handler +{ + +public : + SALOME_Launcher_Handler(ParserLauncherType& launch); + + virtual ~SALOME_Launcher_Handler(); + + const ParserLauncherType& GetLauncherAfterParsing() const; + + void ProcessXmlDocument(xmlDocPtr theDoc); + +private : + ParserLauncherType& _launch; + MachineParameters _machp; + + const char *test_machine_list; + const char *test_main; + + const char *test_machine; + const char *test_env_file; + const char *test_work_directory; + const char *test_ref_directory; + const char *test_nb_processes; + const char *test_input_file; + const char *test_output_file; + const char *test_command; + +}; + +#endif // SALOME_LAUNCHER_HANDLER diff --git a/src/Launcher/SALOME_Launcher_Parser.cxx b/src/Launcher/SALOME_Launcher_Parser.cxx new file mode 100644 index 000000000..f08514c49 --- /dev/null +++ b/src/Launcher/SALOME_Launcher_Parser.cxx @@ -0,0 +1,77 @@ +// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "SALOME_Launcher_Parser.hxx" +#include +#include + +#define NULL_VALUE 0 + +using namespace std; + +void MachineParameters::Clear() +{ + EnvFile = ""; + WorkDirectory = ""; +} + +void MachineParameters::Print() const +{ + ostringstream oss; + oss << " EnvFile: " << EnvFile + << " WorkDirectory: " << WorkDirectory << endl; + + cout << oss.str(); +} + +void ParserLauncherType::Print() const +{ + ostringstream oss; + oss << endl << + "RefDirectory: " << RefDirectory << endl << + "NbOfProcesses: " << NbOfProcesses << endl << + "InputFile: "; + for(int i=0; i ::const_iterator it; + for(it=MachinesList.begin();it!=MachinesList.end();it++){ + cout << " " << it->first; + it->second.Print(); + } + +} + +void ParserLauncherType::Clear() +{ + MachinesList.clear(); + RefDirectory = ""; + NbOfProcesses = 1; + InputFile.clear(); + OutputFile.clear(); + Command = ""; +} diff --git a/src/Launcher/SALOME_Launcher_Parser.hxx b/src/Launcher/SALOME_Launcher_Parser.hxx new file mode 100755 index 000000000..3a29818e1 --- /dev/null +++ b/src/Launcher/SALOME_Launcher_Parser.hxx @@ -0,0 +1,58 @@ +// SALOME ResourcesCatalog : implementation of catalog resources parsing (SALOME_ModuleCatalog.idl) +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : SALOME_Launcher_Parser.hxx +// Author : Bernard Secher +// Module : SALOME +//$Header$ + +#ifndef SALOME_LAUNCHER_PARSER +#define SALOME_LAUNCHER_PARSER + +#include +#include +#include +#include + +struct MachineParameters + { + std::string EnvFile; + std::string WorkDirectory; + void Print() const; + void Clear(); + }; + +struct ParserLauncherType + { + std::map MachinesList; + std::string RefDirectory; + long NbOfProcesses; + std::vector InputFile; + std::vector OutputFile; + std::string Command; + + void Print() const; + void Clear(); + }; + +#endif //SALOME_LAUNCHER_PARSER