condition.cpp
Go to the documentation of this file.
00001 #include <rms/condition.hpp>
00002 #include <sstream>
00003 #include <cstdlib>
00004 
00005 using namespace std;
00006 using namespace librms;
00007 
00008 condition::condition(rms *client, unsigned int id, string name, unsigned int study_id, unsigned int iface_id, unsigned int environment_id, string created, string modified)
00009     :
00010     name_(name), created_(created), modified_(modified)
00011 {
00012   id_ = id;
00013   study_id_ = study_id;
00014   iface_id_ = iface_id;
00015   environment_id_ = environment_id;
00016   client_ = client;
00017   slots_fetched_ = false;
00018 }
00019 
00020 unsigned int condition::get_id() const
00021 {
00022   return id_;
00023 }
00024 
00025 string condition::get_name() const
00026 {
00027   return name_;
00028 }
00029 
00030 
00031 unsigned int condition::get_study_id() const
00032 {
00033   return study_id_;
00034 }
00035 
00036 
00037 unsigned int condition::get_iface_id() const
00038 {
00039   return iface_id_;
00040 }
00041 
00042 
00043 unsigned int condition::get_environment_id() const
00044 {
00045   return environment_id_;
00046 }
00047 
00048 string condition::get_created() const
00049 {
00050   return created_;
00051 }
00052 
00053 string condition::get_modified() const
00054 {
00055   return modified_;
00056 }
00057 
00058 std::vector<slot> &condition::get_slots()
00059 {
00060   if (!slots_fetched_)
00061   {
00062     stringstream ss;
00063     ss << "SELECT * FROM `slots` WHERE `condition_id`=" << id_ << ";";
00064     MYSQL_RES *res = client_->query(ss.str());
00065     if (res)
00066     {
00067       // parse and get it
00068       MYSQL_ROW row;
00069       while ((row = mysql_fetch_row(res)) != NULL)
00070       {
00071         slot c(client_, atoi(row[0]), atoi(row[1]), string(row[2]), string(row[3]), string(row[4]), string(row[5]));
00072         slots_.push_back(c);
00073       }
00074       mysql_free_result(res);
00075       slots_fetched_ = true;
00076     }
00077   }
00078   return slots_;
00079 }


librms
Author(s): Russell Toris
autogenerated on Sat Jun 8 2019 18:47:12