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
00026 #include "worldElementFactory.h"
00027
00028
00029
00030
00031
00032 #include "robot.h"
00033 #include "body.h"
00034 #include "robot.h"
00035 #include "humanHand.h"
00036 #include "robonaut.h"
00037 #include "pr2Gripper.h"
00038 #include "m7.h"
00039 #include "m7tool.h"
00040 #include "barrett.h"
00041 #include "shadow.h"
00042 #include "puma560.h"
00043 #include "mcGrip.h"
00044 #include "robotiq.h"
00045
00046 WorldElementFactory::~WorldElementFactory()
00047 {
00048 for (std::map<std::string, WorldElementCreator*>::iterator it=mCreators.begin(); it!=mCreators.end(); it++)
00049 {
00050 delete it->second;
00051 }
00052 }
00053
00054 WorldElement*
00055 WorldElementFactory::createElement(std::string elementType, World *parent,const char *name)
00056 {
00057 std::map<std::string, WorldElementCreator*>::iterator it = mCreators.find(elementType);
00058 if (it==mCreators.end()) return NULL;
00059 return (*(it->second))(parent, name);
00060 }
00061
00062 void
00063 WorldElementFactory::registerCreator(std::string elementType, WorldElementCreator *creator)
00064 {
00065 mCreators[elementType] = creator;
00066 }
00067
00068 void
00069 WorldElementFactory::registerBuiltinCreators()
00070 {
00071 REGISTER_CREATOR("Body",Body);
00072 REGISTER_CREATOR("GraspableBody",GraspableBody);
00073 REGISTER_CREATOR("Robot",Robot);
00074 REGISTER_CREATOR("Hand",Hand);
00075 REGISTER_CREATOR("Puma560",Puma560);
00076 REGISTER_CREATOR("Barrett",Barrett);
00077 REGISTER_CREATOR("Robonaut",Robonaut);
00078 REGISTER_CREATOR("Pr2Gripper",Pr2Gripper);
00079 REGISTER_CREATOR("Pr2Gripper2010",Pr2Gripper2010);
00080 REGISTER_CREATOR("M7",M7);
00081 REGISTER_CREATOR("M7Tool",M7Tool);
00082 REGISTER_CREATOR("HumanHand",HumanHand);
00083 REGISTER_CREATOR("Shadow",Shadow);
00084 REGISTER_CREATOR("McGrip",McGrip);
00085 REGISTER_CREATOR("RobotIQ",RobotIQ);
00086 }