1 // Copyright (C) 2019 EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #ifndef YDEFX_LAUNCHER_H
20 #define YDEFX_LAUNCHER_H
22 #include "TMonoPyJob.hxx"
30 Launcher():_lastError(){}
31 const std::string& lastError()const{return _lastError;}
34 * Create and submit a new job.
35 * Return nullptr in case of failure. Check the error with lastError().
37 template <class ...Ts>
38 Job* submitMonoPyJob(const PyStudyFunction& fnScript,
39 Sample<Ts...>& sample,
40 const JobParametersProxy& params);
43 * Connect to an already created job.
44 * Return nullptr in case of failure. Check the error with lastError().
46 template <class ...Ts>
47 Job* connectJob(const std::string& jobDump, Sample<Ts...>& sample);
49 template <class ...Ts>
50 Job* submitMultiPyJob(const PyStudyFunction& fn,
51 Sample<Ts...>& sample,
52 const JobParametersProxy& params);
55 std::string _lastError;
58 ////////////////////////////////////////////////////////////////////////////////
59 // Template implementations
60 ////////////////////////////////////////////////////////////////////////////////
62 template <class ...Ts>
63 Job* Launcher::submitMonoPyJob(const PyStudyFunction& fnScript,
64 Sample<Ts...>& sample,
65 const JobParametersProxy& params)
67 Job* result = nullptr;
71 result = new TMonoPyJob<Ts...>(fnScript, sample, params);
73 catch(std::exception& e)
78 _lastError = e.what();
82 if(!result->lastError().empty())
84 _lastError = result->lastError();
92 _lastError = "Failed to submit job.\n";
93 _lastError += result->lastError();
100 template <class ...Ts>
101 Job* Launcher::connectJob(const std::string& jobDump,
102 Sample<Ts...>& sample)
104 Job* result = nullptr;
108 result = new TMonoPyJob<Ts...>(jobDump, sample);
110 catch(std::exception& e)
112 if(result != nullptr)
115 _lastError = e.what();
121 template <class ...Ts>
122 Job* Launcher::submitMultiPyJob(const PyStudyFunction& fn,
123 Sample<Ts...>& sample,
124 const JobParametersProxy& params)
127 _lastError = "Not implemented!";
132 #endif // YDEFX_LAUNCHER_H