lhtransmitterswitchapi.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #include "lhtransmitterswitchapi.h"
  2. #include <QLibrary>
  3. #include <QApplication>
  4. #include <QDebug>
  5. LHTransmitterSwitchAPI::LHTransmitterSwitchAPI()
  6. {
  7. }
  8. LHTransmitterSwitchAPI::~LHTransmitterSwitchAPI()
  9. {
  10. }
  11. /* 加载动态库 */
  12. bool LHTransmitterSwitchAPI::loadLibrary()
  13. {
  14. #ifdef Q_OS_WIN
  15. QString libPath = QApplication::applicationDirPath() + "/libLHTransmitterSwitch.dll";
  16. #elif defined(Q_OS_LINUX)
  17. QString libPath = QApplication::applicationDirPath() + "/libLHTransmitterSwitch.so";
  18. #endif
  19. QLibrary lib(libPath);
  20. if(!lib.load())
  21. {
  22. qDebug() << "load 《LHTransmitterSwitch》 library failed, path: " << libPath;
  23. return false;
  24. }
  25. m_pInit = (pInit)lib.resolve("DoInit");
  26. m_pCreateWindow = (pCreateWindow)lib.resolve("DoCreateWindow");
  27. m_pShowWindow = (pShowWindow)lib.resolve("DoShowWindow");
  28. m_pGetExecPlanFromEQM = (pGetExecPlanFromEQM)lib.resolve("DoGetExecPlanFromEQM");
  29. m_pSaveExecPlanToEQM = (pSaveExecPlanToEQM)lib.resolve("DoSaveExecPlanToEQM");
  30. m_pRelease = (pRelease)lib.resolve("DoRelease");
  31. if(m_pInit == nullptr || m_pCreateWindow == nullptr || m_pShowWindow == nullptr ||
  32. m_pGetExecPlanFromEQM == nullptr || m_pSaveExecPlanToEQM == nullptr || m_pRelease == nullptr)
  33. {
  34. return false;
  35. }
  36. return true;
  37. }
  38. int LHTransmitterSwitchAPI::DoInit(const InitData* pData)
  39. {
  40. if(pData == nullptr)
  41. {
  42. return -1;
  43. }
  44. return m_pInit(pData);
  45. }
  46. int LHTransmitterSwitchAPI::DoCreateWindow(int skintype, QWidget* parent)
  47. {
  48. if(parent == nullptr)
  49. {
  50. return -1;
  51. }
  52. return m_pCreateWindow(skintype, parent);
  53. }
  54. int LHTransmitterSwitchAPI::DoShowWindow(int skintype, bool showWindow)
  55. {
  56. return m_pShowWindow(skintype, showWindow);
  57. }
  58. int LHTransmitterSwitchAPI::DoGetExecPlanFromEQM()
  59. {
  60. return m_pGetExecPlanFromEQM();
  61. }
  62. int LHTransmitterSwitchAPI::DoSaveExecPlanToEQM()
  63. {
  64. return m_pSaveExecPlanToEQM();
  65. }
  66. int LHTransmitterSwitchAPI::DoRelease()
  67. {
  68. return m_pRelease();
  69. }