Back to index

nordugrid-arc-nox  1.1.0~rc6
job_sched_meta.cpp
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004 
00005 #include <iomanip>
00006 #include "job_sched_meta.h"
00007 
00008 namespace Arc {
00009 
00010 JobSchedMetaData::JobSchedMetaData():buffer_(0)
00011 {
00012     // NOP;
00013 }
00014 
00015 JobSchedMetaData::JobSchedMetaData(const JobSchedMetaData &s):buffer_(0)
00016 {
00017     resource_id_ = s.resource_id_;
00018     failure_ = s.failure_;
00019     last_checked_ = s.last_checked_;
00020     last_updated_ = s.last_updated_;
00021     created_ = s.created_;
00022     start_time_ = s.start_time_;
00023     end_time_ = s.end_time_;
00024 }
00025 
00026 JobSchedMetaData::JobSchedMetaData(ByteArray &buffer)
00027 {
00028     int buf_len = 0;
00029     char *buf = buffer.data();
00030     time_t t;
00031     
00032     resource_id_ = buf;
00033     buf_len = resource_id_.size() + 1;
00034     failure_ = buf + buf_len;
00035     buf_len += failure_.size() + 1;
00036     
00037     t = *(time_t *)(buf + buf_len);
00038     buf_len += sizeof(t);
00039     last_updated_.SetTime(t);
00040     
00041     t = *(time_t *)(buf + buf_len);
00042     buf_len += sizeof(t);
00043     last_checked_.SetTime(t);
00044     
00045     t = *(time_t *)(buf + buf_len);
00046     buf_len += sizeof(t);
00047     created_.SetTime(t);
00048     
00049     t = *(time_t *)(buf + buf_len);
00050     buf_len += sizeof(t);
00051     start_time_.SetTime(t);
00052     
00053     t = *(time_t *)(buf + buf_len);
00054     buf_len += sizeof(t);
00055     end_time_.SetTime(t);
00056 }
00057 
00058 ByteArray &JobSchedMetaData::serialize(void)
00059 {
00060     time_t t;
00061     buffer_.clean();
00062     buffer_.append(resource_id_);
00063     buffer_.append(failure_);
00064     t = last_updated_.GetTime();
00065     buffer_.append(&t, sizeof(t));
00066     t = last_checked_.GetTime();
00067     buffer_.append(&t, sizeof(t));
00068     t = created_.GetTime();
00069     buffer_.append(&t, sizeof(t));
00070     t = start_time_.GetTime();
00071     buffer_.append(&t, sizeof(t));
00072     t = end_time_.GetTime();
00073     buffer_.append(&t, sizeof(t));
00074     
00075     return buffer_;
00076 }
00077 
00078 JobSchedMetaData::~JobSchedMetaData(void) 
00079 {
00080     // NOP
00081 }
00082 
00083 JobSchedMetaData::operator std::string(void) const
00084 {
00085     std::string out =   "ResourceID: " + resource_id_ + "\n"
00086                       + "Failure: " + failure_ + "\n"
00087                       + "Last Checked: " + (std::string)last_checked_ + "\n"
00088                       + "Last Updated: " + (std::string)last_updated_ + "\n"
00089                       + "Created: " + (std::string)created_ + "\n"
00090                       + "Start Time: " + (std::string)start_time_ + "\n"
00091                       + "End Time: " + (std::string)end_time_ + "\n";
00092     return out;
00093 }
00094 
00095 } //namespace arc