]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Merge file Launcher_Job_Writer.cxx with class Launcher_XML_Persistence
authorbarate <barate>
Fri, 11 Oct 2013 15:34:17 +0000 (15:34 +0000)
committerbarate <barate>
Fri, 11 Oct 2013 15:34:17 +0000 (15:34 +0000)
src/Launcher/CMakeLists.txt
src/Launcher/Launcher_Job_Writer.cxx [deleted file]
src/Launcher/Launcher_Job_Writer.hxx [deleted file]
src/Launcher/Launcher_XML_Persistence.cxx
src/Launcher/Launcher_XML_Persistence.hxx
src/Launcher/SALOME_Launcher.cxx

index bf351e5d8a98b8c4ca2080f6a0a290442c9cffc7..ea65568d634c3d266c67fea23f77a669cc5d7cfd 100755 (executable)
@@ -67,7 +67,6 @@ SET(Launcher_SOURCES
   Launcher_Job_SALOME.cxx
   Launcher_Job_PythonSALOME.cxx
   Launcher_Job_YACSFile.cxx
-  Launcher_Job_Writer.cxx
   Launcher.cxx
   Launcher_XML_Persistence.cxx
 )
diff --git a/src/Launcher/Launcher_Job_Writer.cxx b/src/Launcher/Launcher_Job_Writer.cxx
deleted file mode 100644 (file)
index 482fefd..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007  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 "Launcher_Job_Writer.hxx"
-#include "Launcher_Job.hxx"
-
-void Launcher::addToXmlDocument(xmlNodePtr root_node, const Launcher::Job* job)
-{
-  // Begin job
-  xmlNodePtr job_node = xmlNewChild(root_node, NULL, xmlCharStrdup("job"), NULL);
-  xmlNewProp(job_node, xmlCharStrdup("type"), xmlCharStrdup(job->getJobType().c_str()));
-  xmlNewProp(job_node, xmlCharStrdup("name"), xmlCharStrdup(job->getJobName().c_str()));
-
-  // Add user part
-  xmlNodePtr node = xmlNewChild(job_node, NULL, xmlCharStrdup("user_part"), NULL);
-
-  xmlNewChild(node, NULL, xmlCharStrdup("job_file"),         xmlCharStrdup(job->getJobFile().c_str()));
-  xmlNewChild(node, NULL, xmlCharStrdup("env_file"),         xmlCharStrdup(job->getEnvFile().c_str()));
-  xmlNewChild(node, NULL, xmlCharStrdup("work_directory"),   xmlCharStrdup(job->getWorkDirectory().c_str()));
-  xmlNewChild(node, NULL, xmlCharStrdup("local_directory"),  xmlCharStrdup(job->getLocalDirectory().c_str()));
-  xmlNewChild(node, NULL, xmlCharStrdup("result_directory"), xmlCharStrdup(job->getResultDirectory().c_str()));
-
-  // Parameters for COORM
-  xmlNewChild(node, NULL, xmlCharStrdup("launcher_file"), xmlCharStrdup(job->getLauncherFile().c_str()));
-
-  // Files
-  xmlNodePtr files_node = xmlNewChild(node, NULL, xmlCharStrdup("files"), NULL);
-  std::list<std::string> in_files  = job->get_in_files();
-  std::list<std::string> out_files = job->get_out_files();
-  for(std::list<std::string>::iterator it = in_files.begin(); it != in_files.end(); it++)
-    xmlNewChild(files_node, NULL, xmlCharStrdup("in_file"), xmlCharStrdup((*it).c_str()));
-  for(std::list<std::string>::iterator it = out_files.begin(); it != out_files.end(); it++)
-    xmlNewChild(files_node, NULL, xmlCharStrdup("out_file"), xmlCharStrdup((*it).c_str()));
-
-  // Resource part
-  resourceParams resource_params = job->getResourceRequiredParams();
-  xmlNodePtr res_node = xmlNewChild(node, NULL, xmlCharStrdup("resource_params"), NULL);
-  xmlNewChild(res_node, NULL, xmlCharStrdup("name"),   xmlCharStrdup(resource_params.name.c_str()));
-  xmlNewChild(res_node, NULL, xmlCharStrdup("hostname"),   xmlCharStrdup(resource_params.hostname.c_str()));
-  xmlNewChild(res_node, NULL, xmlCharStrdup("OS"),   xmlCharStrdup(resource_params.OS.c_str()));
-  std::ostringstream nb_proc_stream;
-  std::ostringstream nb_node_stream;
-  std::ostringstream nb_proc_per_node_stream;
-  std::ostringstream cpu_clock_stream;
-  std::ostringstream mem_mb_stream;
-  nb_proc_stream << resource_params.nb_proc;
-  nb_node_stream << resource_params.nb_node;
-  nb_proc_per_node_stream << resource_params.nb_proc_per_node;
-  cpu_clock_stream << resource_params.cpu_clock;
-  mem_mb_stream << resource_params.mem_mb;
-  xmlNewChild(res_node, NULL, xmlCharStrdup("nb_proc"),            xmlCharStrdup(nb_proc_stream.str().c_str()));
-  xmlNewChild(res_node, NULL, xmlCharStrdup("nb_node"),            xmlCharStrdup(nb_node_stream.str().c_str()));
-  xmlNewChild(res_node, NULL, xmlCharStrdup("nb_proc_per_node"),   xmlCharStrdup(nb_proc_per_node_stream.str().c_str()));
-  xmlNewChild(res_node, NULL, xmlCharStrdup("cpu_clock"),          xmlCharStrdup(cpu_clock_stream.str().c_str()));
-  xmlNewChild(res_node, NULL, xmlCharStrdup("mem_mb"),             xmlCharStrdup(mem_mb_stream.str().c_str()));
-
-  xmlNewChild(node, NULL, xmlCharStrdup("maximum_duration"), xmlCharStrdup(job->getMaximumDuration().c_str()));
-  xmlNewChild(node, NULL, xmlCharStrdup("queue"),            xmlCharStrdup(job->getQueue().c_str()));
-  xmlNewChild(node, NULL, xmlCharStrdup("exclusive"),        xmlCharStrdup(job->getExclusiveStr().c_str()));
-  std::ostringstream mem_per_cpu_stream;
-  mem_per_cpu_stream << job->getMemPerCpu();
-  xmlNewChild(node, NULL, xmlCharStrdup("mem_per_cpu"),      xmlCharStrdup(mem_per_cpu_stream.str().c_str()));
-
-  // For COORM
-  xmlNewChild(node, NULL, xmlCharStrdup("launcher_args"), xmlCharStrdup(job->getLauncherArgs().c_str()));
-
-  // Specific parameters part
-  xmlNodePtr specific_parameters_node = xmlNewChild(node, NULL, xmlCharStrdup("specific_parameters"), NULL);
-  std::map<std::string, std::string> specific_parameters = job->getSpecificParameters();
-  for(std::map<std::string, std::string>::iterator it = specific_parameters.begin(); it != specific_parameters.end(); it++)
-  {
-    xmlNodePtr specific_parameter_node = xmlNewChild(specific_parameters_node, NULL, xmlCharStrdup("specific_parameter"), NULL);
-    xmlNewChild(specific_parameter_node, NULL, xmlCharStrdup("name"), xmlCharStrdup((it->first).c_str()));
-    xmlNewChild(specific_parameter_node, NULL, xmlCharStrdup("value"), xmlCharStrdup((it->second).c_str()));
-  }
-
-  // Run part
-  xmlNodePtr run_node = xmlNewChild(job_node, NULL, xmlCharStrdup("run_part"), NULL);
-  xmlNewChild(run_node, NULL, xmlCharStrdup("job_state"), xmlCharStrdup(job->getState().c_str()));
-  ParserResourcesType resource_definition = job->getResourceDefinition();
-  xmlNewChild(run_node, NULL, xmlCharStrdup("resource_choosed_name"), xmlCharStrdup(resource_definition.Name.c_str()));
-
-#ifdef WITH_LIBBATCH
-  Batch::JobId job_id = job->getBatchManagerJobId();
-  xmlNewChild(run_node, NULL, xmlCharStrdup("job_reference"), xmlCharStrdup(job_id.getReference().c_str()));
-#endif
-}
-
diff --git a/src/Launcher/Launcher_Job_Writer.hxx b/src/Launcher/Launcher_Job_Writer.hxx
deleted file mode 100644 (file)
index fa9f217..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007  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 <libxml/parser.h>
-
-namespace Launcher
-{
-  class Job;
-  void addToXmlDocument(xmlNodePtr root_node, const Job* job);
-}
index b60b14fd5214cbb03568f9cbedfb4b4294a13394..511ffd223b1002d673642c1881b0a637bed2916c 100644 (file)
@@ -26,7 +26,6 @@
 #include "Launcher_Job_Command.hxx"
 #include "Launcher_Job_YACSFile.hxx"
 #include "Launcher_Job_PythonSALOME.hxx"
-#include "Launcher_Job_Writer.hxx"
 
 using namespace std;
 
@@ -517,7 +516,7 @@ XML_Persistence::saveJobs(const char* jobs_file, const list<const Job *> & jobs_
   list<const Job *>::const_iterator it_job;
   for (it_job = jobs_list.begin(); it_job != jobs_list.end(); it_job++)
   {
-    addToXmlDocument(root_node, *it_job);
+    addJobToXmlDocument(root_node, **it_job);
   }
 
   // Final step: write file
@@ -537,4 +536,87 @@ XML_Persistence::saveJobs(const char* jobs_file, const list<const Job *> & jobs_
   LAUNCHER_MESSAGE("SALOME_Launcher::saveJobs : WRITING DONE!");
 }
 
+void
+XML_Persistence::addJobToXmlDocument(xmlNodePtr root_node, const Job & job)
+{
+  // Begin job
+  xmlNodePtr job_node = xmlNewChild(root_node, NULL, xmlCharStrdup("job"), NULL);
+  xmlNewProp(job_node, xmlCharStrdup("type"), xmlCharStrdup(job.getJobType().c_str()));
+  xmlNewProp(job_node, xmlCharStrdup("name"), xmlCharStrdup(job.getJobName().c_str()));
+
+  // Add user part
+  xmlNodePtr node = xmlNewChild(job_node, NULL, xmlCharStrdup("user_part"), NULL);
+
+  xmlNewChild(node, NULL, xmlCharStrdup("job_file"),         xmlCharStrdup(job.getJobFile().c_str()));
+  xmlNewChild(node, NULL, xmlCharStrdup("env_file"),         xmlCharStrdup(job.getEnvFile().c_str()));
+  xmlNewChild(node, NULL, xmlCharStrdup("work_directory"),   xmlCharStrdup(job.getWorkDirectory().c_str()));
+  xmlNewChild(node, NULL, xmlCharStrdup("local_directory"),  xmlCharStrdup(job.getLocalDirectory().c_str()));
+  xmlNewChild(node, NULL, xmlCharStrdup("result_directory"), xmlCharStrdup(job.getResultDirectory().c_str()));
+
+  // Parameters for COORM
+  xmlNewChild(node, NULL, xmlCharStrdup("launcher_file"), xmlCharStrdup(job.getLauncherFile().c_str()));
+
+  // Files
+  xmlNodePtr files_node = xmlNewChild(node, NULL, xmlCharStrdup("files"), NULL);
+  std::list<std::string> in_files  = job.get_in_files();
+  std::list<std::string> out_files = job.get_out_files();
+  for(std::list<std::string>::iterator it = in_files.begin(); it != in_files.end(); it++)
+    xmlNewChild(files_node, NULL, xmlCharStrdup("in_file"), xmlCharStrdup((*it).c_str()));
+  for(std::list<std::string>::iterator it = out_files.begin(); it != out_files.end(); it++)
+    xmlNewChild(files_node, NULL, xmlCharStrdup("out_file"), xmlCharStrdup((*it).c_str()));
+
+  // Resource part
+  resourceParams resource_params = job.getResourceRequiredParams();
+  xmlNodePtr res_node = xmlNewChild(node, NULL, xmlCharStrdup("resource_params"), NULL);
+  xmlNewChild(res_node, NULL, xmlCharStrdup("name"),   xmlCharStrdup(resource_params.name.c_str()));
+  xmlNewChild(res_node, NULL, xmlCharStrdup("hostname"),   xmlCharStrdup(resource_params.hostname.c_str()));
+  xmlNewChild(res_node, NULL, xmlCharStrdup("OS"),   xmlCharStrdup(resource_params.OS.c_str()));
+  std::ostringstream nb_proc_stream;
+  std::ostringstream nb_node_stream;
+  std::ostringstream nb_proc_per_node_stream;
+  std::ostringstream cpu_clock_stream;
+  std::ostringstream mem_mb_stream;
+  nb_proc_stream << resource_params.nb_proc;
+  nb_node_stream << resource_params.nb_node;
+  nb_proc_per_node_stream << resource_params.nb_proc_per_node;
+  cpu_clock_stream << resource_params.cpu_clock;
+  mem_mb_stream << resource_params.mem_mb;
+  xmlNewChild(res_node, NULL, xmlCharStrdup("nb_proc"),            xmlCharStrdup(nb_proc_stream.str().c_str()));
+  xmlNewChild(res_node, NULL, xmlCharStrdup("nb_node"),            xmlCharStrdup(nb_node_stream.str().c_str()));
+  xmlNewChild(res_node, NULL, xmlCharStrdup("nb_proc_per_node"),   xmlCharStrdup(nb_proc_per_node_stream.str().c_str()));
+  xmlNewChild(res_node, NULL, xmlCharStrdup("cpu_clock"),          xmlCharStrdup(cpu_clock_stream.str().c_str()));
+  xmlNewChild(res_node, NULL, xmlCharStrdup("mem_mb"),             xmlCharStrdup(mem_mb_stream.str().c_str()));
+
+  xmlNewChild(node, NULL, xmlCharStrdup("maximum_duration"), xmlCharStrdup(job.getMaximumDuration().c_str()));
+  xmlNewChild(node, NULL, xmlCharStrdup("queue"),            xmlCharStrdup(job.getQueue().c_str()));
+  xmlNewChild(node, NULL, xmlCharStrdup("exclusive"),        xmlCharStrdup(job.getExclusiveStr().c_str()));
+  std::ostringstream mem_per_cpu_stream;
+  mem_per_cpu_stream << job.getMemPerCpu();
+  xmlNewChild(node, NULL, xmlCharStrdup("mem_per_cpu"),      xmlCharStrdup(mem_per_cpu_stream.str().c_str()));
+
+  // For COORM
+  xmlNewChild(node, NULL, xmlCharStrdup("launcher_args"), xmlCharStrdup(job.getLauncherArgs().c_str()));
+
+  // Specific parameters part
+  xmlNodePtr specific_parameters_node = xmlNewChild(node, NULL, xmlCharStrdup("specific_parameters"), NULL);
+  std::map<std::string, std::string> specific_parameters = job.getSpecificParameters();
+  for(std::map<std::string, std::string>::iterator it = specific_parameters.begin(); it != specific_parameters.end(); it++)
+  {
+    xmlNodePtr specific_parameter_node = xmlNewChild(specific_parameters_node, NULL, xmlCharStrdup("specific_parameter"), NULL);
+    xmlNewChild(specific_parameter_node, NULL, xmlCharStrdup("name"), xmlCharStrdup((it->first).c_str()));
+    xmlNewChild(specific_parameter_node, NULL, xmlCharStrdup("value"), xmlCharStrdup((it->second).c_str()));
+  }
+
+  // Run part
+  xmlNodePtr run_node = xmlNewChild(job_node, NULL, xmlCharStrdup("run_part"), NULL);
+  xmlNewChild(run_node, NULL, xmlCharStrdup("job_state"), xmlCharStrdup(job.getState().c_str()));
+  ParserResourcesType resource_definition = job.getResourceDefinition();
+  xmlNewChild(run_node, NULL, xmlCharStrdup("resource_choosed_name"), xmlCharStrdup(resource_definition.Name.c_str()));
+
+#ifdef WITH_LIBBATCH
+  Batch::JobId job_id = job.getBatchManagerJobId();
+  xmlNewChild(run_node, NULL, xmlCharStrdup("job_reference"), xmlCharStrdup(job_id.getReference().c_str()));
+#endif
+}
+
 }
index 772b1e9d34db53d78c7cc2eb613ffaa4e1322a78..e788c858d20831e94e4aabc30439a9e15c951ace 100644 (file)
@@ -30,6 +30,9 @@
 
 namespace Launcher
 {
+  typedef struct _xmlNode xmlNode;
+  typedef xmlNode *xmlNodePtr;
+
   class LAUNCHER_EXPORT XML_Persistence
   {
   public:
@@ -48,6 +51,8 @@ namespace Launcher
     // This class is static only, not instanciable
     XML_Persistence() {}
 
+    static void addJobToXmlDocument(xmlNodePtr root_node, const Job & job);
+
   };
 
 }
index f823275b22924d1398d111368229d186291af18d..e84e3ec9e2c05c39ea0abbfb1c8a2f235d7b8dff 100644 (file)
@@ -30,7 +30,6 @@
 #include "Launcher_Job_Command.hxx"
 #include "Launcher_Job_YACSFile.hxx"
 #include "Launcher_Job_PythonSALOME.hxx"
-#include "Launcher_Job_Writer.hxx"
 
 #ifdef WIN32
 # include <process.h>