device_factory.hpp 772 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef DATACLOUD_DEVICE_FACTORY_H
  2. #define DATACLOUD_DEVICE_FACTORY_H
  3. #include "device_base.hpp"
  4. #include "rslidar/rslidar_driver.h"
  5. class DeviceFactory {
  6. public:
  7. enum LIDAR_DEVICE_TYPE {
  8. LIDAR_RSLIDAR = 0,
  9. LIDAR_WANJI
  10. };
  11. public:
  12. static LidarDevice* createLidar(LIDAR_DEVICE_TYPE type) {
  13. return getLidar(type);
  14. }
  15. protected:
  16. DeviceFactory() {};
  17. virtual ~DeviceFactory() {};
  18. private:
  19. static LidarDevice* getLidar(LIDAR_DEVICE_TYPE &type) {
  20. LidarDevice* device = nullptr;
  21. switch (type)
  22. {
  23. case LIDAR_RSLIDAR:
  24. device = new RS_lidar_device;
  25. break;
  26. default:
  27. break;
  28. }
  29. device->init();
  30. return device;
  31. }
  32. };
  33. #endif