00001 #ifndef GRASP_PLANNING_GRASPIT_GRASPITSCENEMANAGERNOGUI_H 00002 #define GRASP_PLANNING_GRASPIT_GRASPITSCENEMANAGERNOGUI_H 00003 00004 #ifdef DOXYGEN_SHOULD_SKIP_THIS 00005 00024 #endif 00025 00026 #include <string> 00027 #include <grasp_planning_graspit/GraspItSceneManager.h> 00028 00029 class SoIdleSensor; 00030 00031 namespace GraspIt 00032 { 00033 00051 class GraspItSceneManagerHeadless: public GraspItSceneManager 00052 { 00053 public: 00054 GraspItSceneManagerHeadless(); 00055 virtual ~GraspItSceneManagerHeadless(); 00056 00057 virtual bool isReady() const; 00058 00059 virtual void waitUntilReady() const; 00060 00061 protected: 00062 virtual void initializeCore(); 00063 00064 virtual void destroyCore(); 00065 00066 virtual World * createNewGraspitWorld(); 00067 00068 virtual bool eventThreadRunsQt() const 00069 { 00070 return true; 00071 } 00072 00073 00079 virtual bool scheduleIdleEvent(); 00080 00084 bool isInventorReady() const; 00085 00086 private: 00087 GraspItSceneManagerHeadless(const GraspItSceneManagerHeadless& o) {} 00088 00093 void createIdleSensor(); 00094 void deleteIdleSensor(); 00095 00099 static void sensorCB(void *data, SoSensor *); 00100 00106 void waitForInventorState(const bool value) const; 00107 00111 void setInventorReady(const bool flag); 00112 00118 static void ivThreadLoop(GraspItSceneManagerHeadless * _this); 00119 00120 // Thread which runs the inventor loop. 00121 THREAD * ivThread; 00122 00123 // flag set to true as soon as the Inventor environment managed by CoreHeadless is initialized. 00124 bool ivReady; 00125 mutable MUTEX ivReadyMtx; 00126 00127 SoSensor *mIdleSensor; 00128 }; 00129 } // namespace GraspIt 00130 #endif // GRASP_PLANNING_GRASPIT_GRASPITSCENEMANAGERNOGUI_H