Go to the documentation of this file.00001 #include <rms/study.hpp>
00002 #include <sstream>
00003 #include <cstdlib>
00004
00005 using namespace std;
00006 using namespace librms;
00007
00008 study::study(rms *client, unsigned int id, string name, string start, string end, unsigned int length, bool otf, bool parallel, bool repeatable, string created, string modified)
00009 :
00010 name_(name), start_(start), end_(end), created_(created), modified_(modified)
00011 {
00012 id_ = id;
00013 length_ = length;
00014 otf_ = otf;
00015 parallel_ = parallel;
00016 repeatable_ = repeatable;
00017 client_ = client;
00018 }
00019
00020 unsigned int study::get_id() const
00021 {
00022 return id_;
00023 }
00024
00025 string study::get_name() const
00026 {
00027 return name_;
00028 }
00029
00030 string study::get_start() const
00031 {
00032
00033 return start_;
00034 }
00035
00036 string study::get_end() const
00037 {
00038 return end_;
00039 }
00040
00041 unsigned int study::get_length() const
00042 {
00043 return length_;
00044 }
00045
00046 bool study::get_otf() const
00047 {
00048 return otf_;
00049 }
00050
00051 bool study::get_parallel() const
00052 {
00053 return parallel_;
00054 }
00055
00056 bool study::get_repeatable() const
00057 {
00058 return repeatable_;
00059 }
00060
00061 string study::get_created() const
00062 {
00063 return created_;
00064 }
00065
00066 string study::get_modified() const
00067 {
00068 return modified_;
00069 }
00070
00071 std::vector<condition> &study::get_conditions()
00072 {
00073 if (!conditions_fetched_)
00074 {
00075 stringstream ss;
00076 ss << "SELECT * FROM `conditions` WHERE `study_id`=" << id_ << ";";
00077 MYSQL_RES *res = client_->query(ss.str());
00078 if (res)
00079 {
00080
00081 MYSQL_ROW row;
00082 while ((row = mysql_fetch_row(res)) != NULL)
00083 {
00084 condition c(client_, atoi(row[0]), string(row[1]), atoi(row[2]), atoi(row[3]), atoi(row[4]), string(row[5]), string(row[6]));
00085 conditions_.push_back(c);
00086 }
00087 mysql_free_result(res);
00088 conditions_fetched_ = true;
00089 }
00090 }
00091 return conditions_;
00092 }