00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00030 #ifndef DB_PLANNER_SQL_DATABASE_MANAGER_H
00031 #define DB_PLANNER_SQL_DATABASE_MANAGER_H
00032
00033 #include <cstdlib>
00034 #include <string>
00035 #include <vector>
00036 #include "database.h"
00037 #include "db_manager.h"
00038 using std::string;
00039 using std::vector;
00040
00041 namespace db_planner {
00042
00044 class SqlDatabaseManager : public DatabaseManager {
00045 protected:
00047 mutable DatabaseConnection database_;
00048
00050 string model_root_;
00051 public:
00052 SqlDatabaseManager(const string& host_name,
00053 const int port,
00054 const string& user_name,
00055 const string& password,
00056 const string& database_name,
00057 ModelAllocator *model_allocator,
00058 GraspAllocator *grasp_allocator,
00059 const string& connection_type = "QPSQL")
00060 : database_(host_name,
00061 port,
00062 user_name,
00063 password,
00064 database_name,
00065 connection_type),
00066 model_root_(getenv("CGDB_MODEL_ROOT"))
00067 {
00068 model_allocator_ = model_allocator;
00069 grasp_allocator_ = grasp_allocator;
00070 }
00071 ~SqlDatabaseManager(){delete model_allocator_; delete grasp_allocator_;}
00072
00074 void SetGraspAllocator(GraspAllocator* allocator) {
00075 delete grasp_allocator_;
00076 grasp_allocator_ = allocator;
00077 }
00079 void SetModelAllocator(ModelAllocator* allocator) {
00080 delete model_allocator_;
00081 model_allocator_ = allocator;
00082 }
00083
00085 virtual bool isConnected() const {return database_.isConnected();}
00087
00089 virtual bool GetAlignment(const Model& source,
00090 const Model& dest,
00091 const string& alignment_method_name,
00092 float alignment[16]) const;
00094
00095 virtual bool SaveAlignment(const Model& source,
00096 const Model& dest,
00097 const string& alignment_method_name,
00098 const float alignment[16]) const;
00100
00102 virtual bool GetNeighbors(const Model& model,
00103 const string& distance_function_name,
00104 const int num_neighbors,
00105 vector<pair<Model*, double> >* neighbors) const;
00107 virtual bool SaveNeighbors(const Model& model,
00108 const string& distance_function_name,
00109 const vector<pair<Model*, double> >& neighbors) const;
00111 virtual bool GetGrasps(const Model& model,
00112 const string& hand_name,
00113 vector<Grasp*>* grasp_list) const;
00115 virtual bool SaveGrasp(const Grasp* grasp) const;
00117 virtual bool ModelList(vector<Model*>* model_list,
00118 FilterList::FilterType filter = FilterList::NONE) const;
00120 virtual bool GraspTypeList(vector<string>* type_list) const;
00122 virtual bool DistanceFunctionList(
00123 vector<string>* distance_function_list) const;
00125 virtual bool AlignmentMethodList(
00126 vector<string>* alignment_method_list) const;
00127
00128
00129 virtual bool DeleteGrasp(Grasp* ) const {return false;}
00130 virtual bool AcquireNextTask(TaskRecord* ){return false;}
00131 virtual bool SetTaskStatus(int , const string& ){return false;}
00132 virtual bool GetPlanningTaskRecord(int task_id, PlanningTaskRecord* ){return false;}
00133 virtual bool SetGraspClusterRep(Grasp* , bool ) const {return false;}
00134 virtual bool InsertGraspPair(const Grasp* , const Grasp* ) const {return false;}
00135 virtual bool SetGraspTableClearance(Grasp* , double ) const { return false;}
00136 virtual bool LoadModelGeometry(Model*) const {return false;}
00137 virtual bool ScaledModel(Model* &model, int scaled_model_id) const {return false;}
00138 };
00139
00140 }
00141
00142 #endif // DB_PLANNER_SQL_DATABASE_MANAGER