23#include <boost/algorithm/string.hpp>
24#include <boost/format.hpp>
41 if (prop.
exists(
"status")) {
56 if (prop.
exists(
"output")) {
60 if (prop.
exists(
"error")) {
77 std::string converted;
80 converted =
"AVAILABLE";
83 converted =
"ASSIGNED";
89 converted =
"COMPLETE";
92 throw std::runtime_error(
"Incomprehensible status (enum)");
99 if (status ==
"AVAILABLE") {
101 }
else if (status ==
"ASSIGNED") {
103 }
else if (status ==
"FAILED") {
105 }
else if (status ==
"COMPLETE") {
108 throw std::runtime_error(
"Incomprehensible status: " + status);
125 std::string tab =
"\t";
126 ofs << tab <<
"<job>\n";
127 ofs << tab << tab << (format(
"<id>%1$d</id>\n") %
id_).str();
128 ofs << tab << tab << (format(
"<tag>%1$s</tag>\n") %
tag_).str();
134 ofs << tab << tab << (format(
"<host>%1$s</host>\n") %
host_).str();
137 ofs << tab << tab << (format(
"<time>%1$s</time>\n") %
time_).str();
143 ofs << tab << tab << (format(
"<error>%1$s</error>\n") %
error_).str();
145 ofs << tab <<
"</job>\n";
184std::vector<Job>
LOAD_JOBS(
const std::string &job_file) {
189 std::vector<tools::Property *> jobProps = xml.
Select(
"jobs.job");
190 std::vector<Job> jobs;
191 jobs.reserve(jobProps.size());
193 jobs.push_back(
Job(*prop));
199void WRITE_JOBS(
const std::vector<Job> &jobs,
const std::string &job_file) {
201 ofs.open(job_file, std::ofstream::out);
202 if (!ofs.is_open()) {
203 throw std::runtime_error(
"Bad file handle: " + job_file);
205 ofs <<
"<jobs>" << std::endl;
206 for (
auto &job : jobs) {
209 ofs <<
"</jobs>" << std::endl;
215void UPDATE_JOBS(
const std::vector<Job> &from, std::vector<Job> &to,
216 const std::string &thisHost) {
217 std::vector<Job>::iterator it_int;
218 std::vector<Job>::const_iterator it_ext;
220 if (to.size() != from.size()) {
221 throw std::runtime_error(
"Progress file out of sync (::size), abort.");
224 for (it_int = to.begin(), it_ext = from.begin(); it_int != to.end();
225 ++it_int, ++it_ext) {
226 Job &job_int = *it_int;
227 const Job &job_ext = *it_ext;
229 throw std::runtime_error(
"Progress file out of sync (::id), abort.");
const std::string & getError() const
const tools::Property & getOutput() const
JobStatus getStatus() const
const tools::Property & getOutput() const
void ToStream(std::ofstream &ofs) const
const std::string & getError() const
const std::string & getTime() const
const std::string & getHost() const
Job(const tools::Property &prop)
void UpdateFrom(const Job &ext)
const JobStatus & getStatus() const
std::string ConvertStatus(JobStatus) const
void UpdateFromResult(const JobResult &res)
void WRITE_JOBS(const std::vector< Job > &jobs, const std::string &job_file)
void UPDATE_JOBS(const std::vector< Job > &from, std::vector< Job > &to, const std::string &thisHost)
std::vector< Job > LOAD_JOBS(const std::string &xml_file)
base class for all analysis tools