$search
00001 /********************************************************************* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2009, Willow Garage, Inc. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of the Willow Garage nor the names of its 00018 * contributors may be used to endorse or promote products derived 00019 * from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 *********************************************************************/ 00034 00035 // Author(s): Matei Ciocarlie 00036 00037 #ifndef _DATABASE_TASK_H_ 00038 #define _DATABASE_TASK_H_ 00039 00040 #include <database_interface/db_class.h> 00041 00042 namespace household_objects_database { 00043 00045 00049 class DatabaseTaskID : public database_interface::DBClass 00050 { 00051 public: 00052 database_interface::DBField<int> id_; 00053 00054 DatabaseTaskID() : 00055 id_(database_interface::DBFieldBase::TEXT, this, "get_mark_next_dbase_task", "get_mark_next_dbase_task()", false) 00056 { 00057 primary_key_field_ = &id_; 00058 id_.setWriteToDatabase(false); 00059 } 00060 00061 }; 00062 00064 00068 class DatabaseTaskIDTyped : public database_interface::DBClass 00069 { 00070 public: 00071 database_interface::DBField<int> id_; 00072 00073 DatabaseTaskIDTyped() : 00074 id_(database_interface::DBFieldBase::TEXT, this, "get_mark_next_dbase_task_of_type", "foo_bar", false) 00075 { 00076 primary_key_field_ = &id_; 00077 id_.setWriteToDatabase(false); 00078 } 00079 00082 DatabaseTaskIDTyped(std::string function_field) : 00083 id_(database_interface::DBFieldBase::TEXT, this, "get_mark_next_dbase_task_of_type", function_field, false) 00084 { 00085 primary_key_field_ = &id_; 00086 id_.setWriteToDatabase(false); 00087 } 00088 }; 00089 00090 class DatabaseTask : public database_interface::DBClass 00091 { 00092 private: 00093 public: 00094 //primary key 00095 database_interface::DBField<int> id_; 00096 //other fields 00097 database_interface::DBField<std::string> type_; 00098 database_interface::DBField<std::string> outcome_name_; 00099 00100 DatabaseTask() : 00101 id_(database_interface::DBFieldBase::TEXT, this, "dbase_task_id", "dbase_task", true), 00102 type_(database_interface::DBFieldBase::TEXT, this, "dbase_task_type", "dbase_task", true), 00103 outcome_name_(database_interface::DBFieldBase::TEXT, this, "dbase_task_outcome_name", "dbase_task", true) 00104 { 00105 primary_key_field_ = &id_; 00106 fields_.push_back(&type_); 00107 fields_.push_back(&outcome_name_); 00108 00109 setAllFieldsReadFromDatabase(true); 00110 setAllFieldsWriteToDatabase(true); 00111 00112 id_.setSequenceName("task_id_seq"); 00113 id_.setWriteToDatabase(false); 00114 } 00115 }; 00116 00118 class DatabasePlanningTask : public database_interface::DBClass 00119 { 00120 public: 00121 //primary key; also foreign key from the dbase_task table 00122 database_interface::DBField<int> id_; 00123 //other fields 00124 database_interface::DBField<int> scaled_model_id_; 00125 database_interface::DBField<std::string> hand_name_; 00126 database_interface::DBField<int> time_; 00127 00128 DatabasePlanningTask() : 00129 id_(database_interface::DBFieldBase::TEXT, this, "dbase_task_id", "planning_task", true), 00130 scaled_model_id_(database_interface::DBFieldBase::TEXT, this, "scaled_model_id", "planning_task", true), 00131 hand_name_(database_interface::DBFieldBase::TEXT, this, "hand_name", "planning_task", true), 00132 time_(database_interface::DBFieldBase::TEXT, this, "task_time", "planning_task", true) 00133 { 00134 primary_key_field_ = &id_; 00135 fields_.push_back(&scaled_model_id_); 00136 fields_.push_back(&hand_name_); 00137 fields_.push_back(&time_); 00138 00139 setAllFieldsReadFromDatabase(true); 00140 setAllFieldsWriteToDatabase(true); 00141 } 00142 00143 }; 00144 00145 class DatabaseOptimizationTask : public database_interface::DBClass 00146 { 00147 public: 00148 //primary key and also foreign key from the dbase_task table 00149 database_interface::DBField<int> dbase_task_id_; 00150 //other fields 00151 database_interface::DBField<std::string> hand_name_; 00152 database_interface::DBField< std::vector<double> > parameters_; 00153 00154 DatabaseOptimizationTask() : 00155 dbase_task_id_(database_interface::DBFieldBase::TEXT, this, "dbase_task_id", "optimization_task", true), 00156 hand_name_(database_interface::DBFieldBase::TEXT, this, "hand_name", "optimization_task", true), 00157 parameters_(database_interface::DBFieldBase::TEXT, this, "optimization_task_parameters", "optimization_task", true) 00158 { 00159 primary_key_field_ = &dbase_task_id_; 00160 fields_.push_back(&hand_name_); 00161 fields_.push_back(¶meters_); 00162 00163 setAllFieldsReadFromDatabase(true); 00164 setAllFieldsWriteToDatabase(true); 00165 } 00166 }; 00167 00168 class DatabaseOptimizationResult : public database_interface::DBClass 00169 { 00170 public: 00171 database_interface::DBField<int> id_; 00172 database_interface::DBField<int> dbase_task_id_; 00173 database_interface::DBField<std::string> hand_name_; 00174 database_interface::DBField< std::vector<double> > parameters_; 00175 database_interface::DBField< std::vector<double> > results_; 00176 database_interface::DBField< std::vector<double> > seed_; 00177 00178 DatabaseOptimizationResult() : 00179 id_(database_interface::DBFieldBase::TEXT, this, 00180 "optimization_result_id", "optimization_result", true), 00181 dbase_task_id_(database_interface::DBFieldBase::TEXT, this, 00182 "dbase_task_id", "optimization_result", true), 00183 hand_name_(database_interface::DBFieldBase::TEXT, this, 00184 "hand_name", "optimization_result", true), 00185 parameters_(database_interface::DBFieldBase::TEXT, this, 00186 "optimization_result_parameters", "optimization_result", true), 00187 results_(database_interface::DBFieldBase::TEXT, this, 00188 "optimization_result_results", "optimization_result", true), 00189 seed_(database_interface::DBFieldBase::TEXT, this, 00190 "optimization_result_seed", "optimization_result", true) 00191 { 00192 primary_key_field_ = &id_; 00193 fields_.push_back(&dbase_task_id_); 00194 fields_.push_back(&hand_name_); 00195 fields_.push_back(¶meters_); 00196 fields_.push_back(&results_); 00197 fields_.push_back(&seed_); 00198 00199 setAllFieldsReadFromDatabase(true); 00200 setAllFieldsWriteToDatabase(true); 00201 00202 id_.setSequenceName("optimization_result_id_seq"); 00203 id_.setWriteToDatabase(false); 00204 } 00205 }; 00206 00207 } //namespace 00208 00209 #endif