lhtransmitterswitchapi.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. m_pSetCallBack = (pSetCallBack)lib.resolve("DoSetCallBack");
  32. if(m_pInit == nullptr || m_pCreateWindow == nullptr || m_pShowWindow == nullptr ||
  33. m_pGetExecPlanFromEQM == nullptr || m_pSaveExecPlanToEQM == nullptr ||
  34. m_pRelease == nullptr || m_pSetCallBack == nullptr)
  35. {
  36. return false;
  37. }
  38. return true;
  39. }
  40. int LHTransmitterSwitchAPI::DoInit(const InitData* pData)
  41. {
  42. if(pData == nullptr)
  43. {
  44. return -1;
  45. }
  46. return m_pInit(pData);
  47. }
  48. int LHTransmitterSwitchAPI::DoCreateWindow(int skintype, QWidget* parent)
  49. {
  50. if(parent == nullptr)
  51. {
  52. return -1;
  53. }
  54. return m_pCreateWindow(skintype, parent);
  55. }
  56. int LHTransmitterSwitchAPI::DoShowWindow(int skintype, bool showWindow)
  57. {
  58. return m_pShowWindow(skintype, showWindow);
  59. }
  60. int LHTransmitterSwitchAPI::DoGetExecPlanFromEQM()
  61. {
  62. return m_pGetExecPlanFromEQM();
  63. }
  64. int LHTransmitterSwitchAPI::DoSaveExecPlanToEQM()
  65. {
  66. return m_pSaveExecPlanToEQM();
  67. }
  68. int LHTransmitterSwitchAPI::DoRelease()
  69. {
  70. return m_pRelease();
  71. }
  72. int LHTransmitterSwitchAPI::DoSetCallBack(trackCallBack cb)
  73. {
  74. return m_pSetCallBack(cb);
  75. }