rms.h
Go to the documentation of this file.
00001 
00011 #ifndef RMS_H_
00012 #define RMS_H_
00013 
00014 #include <curl/curl.h>
00015 #include <json/json.h>
00016 #include <rmscpp/config/javascript_files/javascript_file.h>
00017 #include <rmscpp/content/articles/article.h>
00018 #include <rmscpp/content/content_pages/content_page.h>
00019 #include <rmscpp/content/slides/slide.h>
00020 #include <rmscpp/user_studies/experiments/experiment.h>
00021 #include <rmscpp/user_studies/conditions/condition.h>
00022 #include <rmscpp/user_studies/studies/study.h>
00023 #include <rmscpp/user_studies/study_logs/study_log.h>
00024 #include <rmscpp/users/user_accounts/user_account.h>
00025 #include <string>
00026 #include <vector>
00027 
00032 namespace rms
00033 {
00038 enum PROTOCOL
00039 {
00040   HTTP_PROTOCOL, HTTPS_PROTOCOL
00041 };
00042 
00043 const std::string API = "/api/"; 
00045 const std::string JAVASCRIPT_FILES_DEFAULT = "config/javascript_files/"; 
00046 const std::string JAVASCRIPT_FILES_ID_FIELD = "id"; 
00048 const std::string ARTICLES_DEFAULT = "content/articles/"; 
00049 const std::string ARTICLES_ID_FIELD = "id"; 
00050 const std::string ARTICLES_PAGES_ID_FIELD = "pageid"; 
00052 const std::string CONTENT_PAGES_DEFAULT = "content/content_pages/"; 
00053 const std::string CONTENT_PAGES_ID_FIELD = "id"; 
00055 const std::string SLIDES_DEFAULT = "content/slides/"; 
00057 const std::string CONDITIONS_DEFAULT = "user_studies/conditions/"; 
00058 const std::string CONDITIONS_ID_FIELD = "id"; 
00060 const std::string EXPERIMENTS_DEFAULT = "user_studies/experiments/"; 
00061 const std::string EXPERIMENTS_ID_FIELD = "id"; 
00063 const std::string STUDIES_DEFAULT = "user_studies/studies/"; 
00064 const std::string STUDIES_ID_FIELD = "id"; 
00066 const std::string STUDY_LOGS_DEFAULT = "user_studies/study_logs/"; 
00067 const std::string STUDY_LOGS_ID_FIELD = "id"; 
00068 const std::string STUDY_LOGS_EXPERIMENTS_ID_FIELD = "expid"; 
00070 const std::string USER_ACCOUNTS_DEFAULT = "users/user_accounts/"; 
00071 const std::string USER_ACCOUNTS_ID_FIELD = "id"; 
00077 typedef struct
00078 {
00079   char *data; 
00080   size_t size; 
00081 } rms_response;
00082 
00089 class rms_client
00090 {
00091 public:
00099   rms_client(std::string host, int port = 80, rms::PROTOCOL protocol = HTTP_PROTOCOL);
00103   virtual ~rms_client();
00110   void set_authorization(std::string username, std::string password);
00111 
00117   std::vector<rms::javascript_file> get_javascript_files();
00124   rms::javascript_file get_javascript_file_by_id(int fileid);
00125 
00131   std::vector<rms::article> get_articles();
00138   rms::article get_article_by_id(int artid);
00145   std::vector<rms::article> get_articles_by_pageid(int pageid);
00146 
00152   std::vector<rms::content_page> get_content_pages();
00159   rms::content_page get_content_page_by_id(int pageid);
00160 
00166   std::vector<rms::slide> get_slides();
00167 
00173   std::vector<rms::condition> get_conditions();
00180   rms::condition get_condition_by_id(int condid);
00181 
00187   std::vector<rms::experiment> get_experiments();
00194   rms::experiment get_experiment_by_id(int expid);
00195 
00201   std::vector<rms::study> get_studies();
00208   rms::study get_study_by_id(int studyid);
00209 
00215   std::vector<rms::study_log> get_study_logs();
00222   rms::study_log get_study_log_by_id(int logid);
00229   std::vector<rms::study_log> get_study_logs_by_expid(int expid);
00230 
00236   std::vector<rms::user_account> get_user_accounts();
00243   rms::user_account get_user_account_by_id(int userid);
00244 private:
00245   std::string url_start; 
00246   CURL *curl; 
00254   std::vector<rms::javascript_file> parse_javascript_files_array(json_object *json_array);
00261   rms::javascript_file parse_javascript_file(json_object *json);
00262 
00269   std::vector<rms::article> parse_articles_array(json_object *json_array);
00276   rms::article parse_article(json_object *json);
00277 
00284   std::vector<rms::content_page> parse_content_pages_array(json_object *json_array);
00291   rms::content_page parse_content_page(json_object *json);
00292 
00299   std::vector<rms::slide> parse_slides_array(json_object *json_array);
00306   rms::slide parse_slide(json_object *json);
00307 
00314   std::vector<rms::condition> parse_conditions_array(json_object *json_array);
00321   rms::condition parse_condition(json_object *json);
00322 
00329   std::vector<rms::experiment> parse_experiments_array(json_object *json_array);
00336   rms::experiment parse_experiment(json_object *json);
00337 
00344   std::vector<rms::study> parse_studies_array(json_object *json_array);
00351   rms::study parse_study(json_object *json);
00352 
00359   std::vector<rms::study_log> parse_study_logs_array(json_object *json_array);
00366   rms::study_log parse_study_log(json_object *json);
00367 
00374   std::vector<rms::user_account> parse_user_accounts_array(json_object *json_array);
00381   rms::user_account parse_user_account(json_object *json);
00382 
00390   std::string extract_json_string(json_object *json, std::string key);
00398   bool extract_json_bool(json_object *json, std::string key);
00406   int extract_json_int(json_object *json, std::string key);
00407 
00414   json_object *make_request(std::string url);
00419   void free_rms_response(rms::rms_response *buf);
00420 };
00421 
00431 size_t write_data(char *ptr, size_t size, size_t nmemb, rms::rms_response *buf);
00432 }
00433 
00434 #endif


rmscpp
Author(s): Russell Toris
autogenerated on Sat Dec 28 2013 17:08:57