Go to the documentation of this file.00001 #ifndef GRASP_PLANNING_GRASPIT_GRASPITSIMPLEDBMANAGER_H
00002 #define GRASP_PLANNING_GRASPIT_GRASPITSIMPLEDBMANAGER_H
00003
00025 #include <grasp_planning_graspit/GraspItDatabaseManager.h>
00026 #include <grasp_planning_graspit/ThreadImpl.h>
00027 #include <map>
00028 #include <utility>
00029 #include <string>
00030 #include <vector>
00031
00032 namespace GraspIt
00033 {
00034
00035 class GraspItSceneManager;
00036
00044 class GraspItSimpleDBManager: public GraspItDatabaseManager
00045 {
00046 public:
00049 GraspItSimpleDBManager(const std::string& objectName, const SHARED_PTR<GraspItSceneManager>& interface):
00050 GraspItDatabaseManager(objectName, interface),
00051 modelIdCounter(0)
00052 {
00053 }
00054 virtual ~GraspItSimpleDBManager()
00055 {
00056
00057 }
00058
00059
00060 virtual int loadRobotToDatabase(const std::string& filename, const std::string& robotName,
00061 const std::vector<std::string>& jointNames);
00062
00063 virtual int loadObjectToDatabase(const std::string& filename, const std::string& robotName, const bool asGraspable);
00064
00065 virtual void getAllLoadedRobotNames(std::vector<std::string>& names) const;
00066
00067 virtual void getAllLoadedRobotIDs(std::vector<int>& ids) const;
00068
00069 virtual void getAllLoadedObjectNames(std::vector<std::string>& names) const;
00070
00071 virtual void getAllLoadedObjectIDs(std::vector<int>& ids) const;
00072
00073 virtual bool getRobotModelID(const std::string& robotName, int& id) const;
00074
00075 virtual bool getObjectModelID(const std::string& objectName, int& id) const;
00076
00077 virtual bool getModelNameAndType(const int modelID, std::string& name, bool& isRobot) const;
00078
00079 virtual bool getRobotJointNames(const std::string& robotName,
00080 std::vector<std::string>& jointNames) const;
00081
00082 protected:
00086 virtual void idleEventFromSceneManager() {}
00087 virtual void onSceneManagerShutdown() {}
00088
00089 virtual Robot * getRobotFromDatabase(const std::string& robotName);
00090 virtual Robot * getRobotFromDatabase(const int modelID);
00091
00092 virtual Body * getObjectFromDatabase(const std::string& objectName);
00093 virtual Body * getObjectFromDatabase(const int modelID);
00094
00095 virtual int getModelType(const int modelID) const;
00096
00097 private:
00098
00099 std::map<std::string, Body*> objects;
00100
00101
00102 std::map<std::string, Robot*> robots;
00103
00104
00105
00106
00107 typedef std::map<int, std::pair<std::string, bool> > ModelIdMap;
00108
00109
00110
00111 typedef std::map<std::string, std::vector<std::string> > RobotJointNamesMap;
00112
00113 ModelIdMap modelIDs;
00114
00115 RobotJointNamesMap robotJointNames;
00116
00117
00118
00119
00120 RECURSIVE_MUTEX dbMtx;
00121
00122
00123 int modelIdCounter;
00124 };
00125
00126 }
00127 #endif // GRASP_PLANNING_GRASPIT_GRASPITSIMPLEDBMANAGER_H