b3PluginManager.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #ifndef B3_PLUGIN_MANAGER_H
  2. #define B3_PLUGIN_MANAGER_H
  3. #include "plugins/b3PluginAPI.h"
  4. enum b3PluginManagerTickMode
  5. {
  6. B3_PRE_TICK_MODE = 1,
  7. B3_POST_TICK_MODE,
  8. B3_PROCESS_CLIENT_COMMANDS_TICK,
  9. };
  10. struct b3PluginFunctions
  11. {
  12. //required
  13. PFN_INIT m_initFunc;
  14. PFN_EXIT m_exitFunc;
  15. PFN_EXECUTE m_executeCommandFunc;
  16. //optional
  17. PFN_TICK m_preTickFunc;
  18. PFN_TICK m_postTickFunc;
  19. PFN_GET_RENDER_INTERFACE m_getRendererFunc;
  20. PFN_TICK m_processClientCommandsFunc;
  21. PFN_TICK m_processNotificationsFunc;
  22. PFN_GET_COLLISION_INTERFACE m_getCollisionFunc;
  23. PFN_GET_FILEIO_INTERFACE m_fileIoFunc;
  24. b3PluginFunctions(PFN_INIT initFunc, PFN_EXIT exitFunc, PFN_EXECUTE executeCommandFunc)
  25. :m_initFunc(initFunc),
  26. m_exitFunc(exitFunc),
  27. m_executeCommandFunc(executeCommandFunc),
  28. m_preTickFunc(0),
  29. m_postTickFunc(0),
  30. m_getRendererFunc(0),
  31. m_processClientCommandsFunc(0),
  32. m_processNotificationsFunc(0),
  33. m_getCollisionFunc(0),
  34. m_fileIoFunc(0)
  35. {
  36. }
  37. };
  38. class b3PluginManager
  39. {
  40. struct b3PluginManagerInternalData* m_data;
  41. public:
  42. b3PluginManager(class PhysicsCommandProcessorInterface* physSdk);
  43. virtual ~b3PluginManager();
  44. int loadPlugin(const char* pluginPath, const char* postFixStr = "");
  45. void unloadPlugin(int pluginUniqueId);
  46. int executePluginCommand(int pluginUniqueId, const struct b3PluginArguments* arguments);
  47. void addEvents(const struct b3VRControllerEvent* vrControllerEvents, int numVRControllerEvents, const struct b3KeyboardEvent* keyEvents, int numKeyEvents, const struct b3MouseEvent* mouseEvents, int numMouseEvents);
  48. void clearEvents();
  49. void addNotification(const struct b3Notification& notification);
  50. void reportNotifications();
  51. void tickPlugins(double timeStep, b3PluginManagerTickMode tickMode);
  52. int registerStaticLinkedPlugin(const char* pluginPath, b3PluginFunctions& functions, bool initPlugin = true);
  53. void selectPluginRenderer(int pluginUniqueId);
  54. struct UrdfRenderingInterface* getRenderInterface();
  55. void selectFileIOPlugin(int pluginUniqueId);
  56. struct CommonFileIOInterface* getFileIOInterface();
  57. void selectCollisionPlugin(int pluginUniqueId);
  58. struct b3PluginCollisionInterface* getCollisionInterface();
  59. const struct b3UserDataValue* getReturnData(int pluginUniqueId);
  60. };
  61. #endif //B3_PLUGIN_MANAGER_H