Go to the documentation of this file.00001
00022 #include <grasp_planning_graspit/GraspItAccessor.h>
00023 #include <grasp_planning_graspit/LogBinding.h>
00024 #include <string>
00025
00026 using GraspIt::GraspItAccessor;
00027 using GraspIt::GraspItSceneManager;
00028
00029 GraspItAccessor::GraspItAccessor(const std::string& objectName, const SHARED_PTR<GraspItSceneManager>& interface):
00030 graspItInterface(interface),
00031 name(objectName),
00032 registered(false),
00033 scheduled(false)
00034 {
00035 }
00036
00037 GraspItAccessor::~GraspItAccessor()
00038 {
00039
00040 if (registered)
00041 {
00042 PRINTERROR("Method GraspItAccessor::removeFromIdleListeners() has not been called by subclass destructor! This may lead to memory corruption.");
00043 }
00044 }
00045
00046
00047 std::string GraspItAccessor::getName() const
00048 {
00049 return name;
00050 }
00051
00052 bool GraspItAccessor::addAsIdleListener()
00053 {
00054 registered = graspItInterface->addIdleListener(this);
00055 }
00056
00057 bool GraspItAccessor::removeFromIdleListeners()
00058 {
00059 registered = !graspItInterface->removeIdleListener(this);
00060 }
00061
00062
00063 void GraspItAccessor::scheduleForIdleEventUpdate()
00064 {
00065 UNIQUE_LOCK(scheduledMtx);
00066 scheduled = true;
00067 graspItInterface->scheduleIdleEvent();
00068 }
00069
00070 void GraspItAccessor::unschedule()
00071 {
00072 UNIQUE_LOCK(scheduledMtx);
00073 scheduled = false;
00074 }
00075
00076 bool GraspItAccessor::isScheduledForIdleEvent() const
00077 {
00078 UNIQUE_LOCK(scheduledMtx);
00079 return scheduled;
00080 }
00081
00082
00083 const SHARED_PTR<GraspItSceneManager>& GraspItAccessor::getGraspItSceneManager()
00084 {
00085 return graspItInterface;
00086 }
00087 const SHARED_PTR<const GraspItSceneManager> GraspItAccessor::readGraspItSceneManager() const
00088 {
00089 return graspItInterface;
00090 }
00091
00092 bool GraspItAccessor::eventThreadRunsQt() const
00093 {
00094 return true;
00095 }
00096
00097 bool GraspItAccessor::tryLockWorld()
00098 {
00099 return graspItInterface->tryLockWorld();
00100 }
00101
00102 void GraspItAccessor::lockWorld()
00103 {
00104 graspItInterface->lockWorld();
00105 }
00106
00107 void GraspItAccessor::unlockWorld()
00108 {
00109 graspItInterface->unlockWorld();
00110 }
00111
00112 UNIQUE_RECURSIVE_LOCK GraspItAccessor::getUniqueWorldLock()
00113 {
00114 return graspItInterface->getUniqueWorldLock();
00115 }
00116
00117 Hand * GraspItAccessor::getCurrentHand()
00118 {
00119 return graspItInterface->getCurrentHand();
00120 }
00121
00122 const Hand * GraspItAccessor::readCurrentHand() const
00123 {
00124 return graspItInterface->readCurrentHand();
00125 }
00126
00127 GraspableBody * GraspItAccessor::getCurrentGraspableBody()
00128 {
00129 return graspItInterface->getCurrentGraspableBody();
00130 }
00131
00132 const GraspableBody * GraspItAccessor::readCurrentGraspableBody() const
00133 {
00134 return graspItInterface->readCurrentGraspableBody();
00135 }
00136
00137 Robot * GraspItAccessor::getRobot(const std::string& name)
00138 {
00139 return graspItInterface->getRobot(name);
00140 }
00141
00142 Robot * GraspItAccessor::getRobot(const unsigned int i)
00143 {
00144 return graspItInterface->getRobot(i);
00145 }
00146
00147 GraspableBody * GraspItAccessor::getGraspableBody(const std::string& name)
00148 {
00149 return graspItInterface->getGraspableBody(name);
00150 }
00151
00152 GraspableBody * GraspItAccessor::getGraspableBody(const unsigned int i)
00153 {
00154 return graspItInterface->getGraspableBody(i);
00155 }
00156
00157 Body * GraspItAccessor::getBody(const std::string& name)
00158 {
00159 return graspItInterface->getBody(name);
00160 }
00161
00162 Body * GraspItAccessor::getBody(const unsigned int i)
00163 {
00164 return graspItInterface->getBody(i);
00165 }
00166
00167 bool GraspItAccessor::isRobotLoaded(const Robot * robot) const
00168 {
00169 return graspItInterface->isRobotLoaded(robot);
00170 }
00171 bool GraspItAccessor::isObjectLoaded(const Body * object) const
00172 {
00173 return graspItInterface->isObjectLoaded(object);
00174 }
00175
00176
00177 bool GraspItAccessor::removeElement(WorldElement* elem, const bool deleteInstance)
00178 {
00179 return graspItInterface->removeElement(elem, deleteInstance);
00180 }
00181
00182 int GraspItAccessor::addRobot(Robot* robot, const EigenTransform& worldTransform)
00183 {
00184 return graspItInterface->addRobot(robot, worldTransform);
00185 }
00186
00187 int GraspItAccessor::addBody(Body* body, const EigenTransform& worldTransform)
00188 {
00189 return graspItInterface->addBody(body, worldTransform);
00190 }