17 #ifndef FCSTDATABASE_H_
18 #define FCSTDATABASE_H_
42 #include <boost/algorithm/string.hpp>
44 namespace FcstUtilities
149 bool connect(
const std::string& db_path_,
const bool& create_if_does_not_exist =
false);
181 bool has_data(
const std::string& model_name,
const DatabaseOC& OC,
const double& tolerance);
193 std::vector<std::vector<double>>
get_data(
const std::string& model_name,
const DatabaseOC& OC);
206 std::vector<std::vector<double>>
get_data(
const std::string& model_name,
const DatabaseOC& OC,
const double& tolerance);
218 std::vector<std::vector<double>>
get_data(
const std::string& model_name,
const DatabaseOC& OC,
const double& tolerance,
const std::string& orderby);
235 bool commit_data(
const std::string& model_name,
const DatabaseOC& OC,
const std::vector<std::string>& column_names,
const std::vector<std::vector<double>>& data);
246 std::vector<std::vector<std::string>>
request(
const std::string& sqlCmd);
282 std::vector<std::vector<std::string>>
temp;
288 static int callback(
void *db_,
int argc,
char **argv,
char **azColName){
291 std::vector<std::string> line_temp;
292 std::string str_temp;
293 for(
int i=0; i<argc; i++){
294 str_temp = argv[i] ? argv[i] :
"NULL";
295 line_temp.push_back(std::string(str_temp));
298 db->
temp.push_back(line_temp);
312 bool create_table(
const std::string& table_name,
const std::vector<std::string>& column_names);
318 bool fill_empty_table(
const std::string& table_name,
const std::vector<std::vector<double>>& data,
const std::vector<std::string>& column_names);
326 std::string
find_table(
const std::string& model_name,
const DatabaseOC& OC,
const double& tolerance);
329 bool find_matching_head_term(
const std::vector<std::string>& OC,
const std::vector<std::string>& head_line,
const double& tolerance);
353 bool request(
const std::string& sqlCmd,
const bool& useCallBack,
int lockCounter =
max_lock);
385 bool add_param(
const std::string& name,
const double& value);
386 bool add_param(
const std::string&,
const std::string& );
std::string find_table(const std::string &model_name, const DatabaseOC &OC)
std::vector< std::vector< double > > get_data(const std::string &model_name, const DatabaseOC &OC)
Function for getting numerical information for a given model and operating conditions.
sqlite3 * db
Definition: fcst_db.h:271
This class is for storing a list of up to 10 parameters and is used as a way of informing the FCSTdat...
Definition: fcst_db.h:368
bool request_no_callback(const std::string &sqlCmd)
bool disconnect()
Function for disconnecting to SQL database.
bool fill_empty_table(const std::string &table_name, const std::vector< std::vector< double >> &data, const std::vector< std::string > &column_names)
virtual ~FCSTdatabase()
Destructor.
bool has_data(const std::string &model_name, const DatabaseOC &OC)
Function for testing if db that you are connected to has data for a given model and operating conditi...
unsigned int max_milli
Definition: fcst_db.h:343
void clear()
Function for clearing parameter data so one can reuse the same object more than once.
Definition: fcst_db.h:391
bool connect()
Function for connecting to default SQL database, located at fcst_root/main_db.
int num_param
Definition: fcst_db.h:408
void cleanUp()
Function which performs database cleanup, removing erroneous data occurring from SQL errors...
bool create_new_db(const std::string &filePath)
Function for creating a new default db.
int max_param
Definition: fcst_db.h:409
bool connected
Definition: fcst_db.h:276
std::vector< std::vector< std::string > > request(const std::string &sqlCmd)
Wrapper Function for performing direct SQL requests.
bool clear_data(const std::string &model_name, const DatabaseOC &OC)
Function for clearing data for a given model and operating conditions.
bool commit_data(const std::string &model_name, const DatabaseOC &OC, const std::vector< std::string > &column_names, const std::vector< std::vector< double >> &data)
Function for committing numerical information for a given model and operating conditions.
static int callback(void *db_, int argc, char **argv, char **azColName)
Definition: fcst_db.h:288
bool find_matching_head_term(const std::vector< std::string > &OC, const std::vector< std::string > &head_line, const double &tolerance)
std::string make_new_head_entry(const std::string &model_name, const DatabaseOC &OC)
FCSTdatabase()
Constructor.
std::string db_path
Definition: fcst_db.h:277
std::vector< std::vector< std::string > > param_data
Definition: fcst_db.h:410
static const int max_lock
Definition: fcst_db.h:342
double lock_time
Definition: fcst_db.h:344
std::vector< std::vector< std::string > > temp
Definition: fcst_db.h:282
bool create_table(const std::string &table_name, const std::vector< std::string > &column_names)
bool add_param(const std::string &name, const double &value)
Function for adding a parameter (name and value pair) to the list of up to 5 parameters.
This class is for interfacing with SQL databases, for the purpose of accessing and storing simulation...
Definition: fcst_db.h:134
bool compare(const DatabaseOC &other, const double &tolerance)
Function for performing a tolerance based comparison of OC object with another OC object...