ToolDepository.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #pragma once
  2. #include "Common.h"
  3. /// <summary>
  4. /// 工具仓库类,用于从dll中加载所有的工具信息
  5. /// 本项目中将工具的静态信息和动态信息分开定义
  6. /// </summary>
  7. class ToolDepository
  8. {
  9. public:
  10. ToolDepository();
  11. virtual ~ToolDepository();
  12. // 加载文件中保存的工具信息
  13. bool LoadTools();
  14. // 获取指定DLL的指针
  15. DllTool* GetToolPtr(const QString& strToolName);
  16. // 2022-10-4,查询指定Dll的全路径
  17. QString GetDllPathByName(const QString& strToolName);
  18. // 直接获取输出Port
  19. const STATIC_TOOL* GetOutputPort() const
  20. {
  21. return &m_toolPortOutput;
  22. }
  23. // 直接获取输出Port
  24. const STATIC_TOOL* GetInputPort() const
  25. {
  26. return &m_toolPortInput;
  27. }
  28. // 通过名称获取工具的指针
  29. TOOL* getToolByName(QString strName);
  30. //// 检测Tool的有效性
  31. //bool ValidateTool(const TOOL& toolInfo);
  32. public:
  33. QVector<TOOL_CATEGORY> m_TotalTools; // 工具箱中所有的工具
  34. protected:
  35. // 从文件中加载工具信息
  36. bool LoadFromFile(const QString& strPath);
  37. // 从dll中提取工具信息
  38. bool ParseToolsFromDll(const QString& strDllPath, const QString& strDllName);
  39. // 将工具信息添加到Category中
  40. bool AddToCategory(const STATIC_TOOL& newTool, const QString& strCategoryName);
  41. // 2021-3-29增加,直接在内部生成port工具,不从外部加载了
  42. void createPortTool();
  43. // 2022-3-13 生成内置注释工具
  44. void createCommentTool();
  45. // 2022-3-22 生成内置的Goto工具
  46. void createGotoTool();
  47. // 2022-4-18 生成内置的并行计算工具
  48. void createParallelTool();
  49. // 2022-8-22 生成内置的For循环工具
  50. void createForLoopTool();
  51. // 2022-9-2 生成内置的等待Event工具
  52. void createWaitTool();
  53. protected:
  54. // 内部直接生成的port工具
  55. STATIC_TOOL m_toolPortOutput;
  56. STATIC_TOOL m_toolPortInput;
  57. // 2022-3-13 内置的注释工具
  58. STATIC_TOOL m_toolComment;
  59. // 2022-3-22 内置的Goto工具
  60. STATIC_TOOL m_toolGoto;
  61. // 2022-4-18 内置的并行计算工具
  62. STATIC_TOOL m_toolParallel;
  63. // 2022-8-22 内置的For循环工具
  64. STATIC_TOOL m_toolForLoop;
  65. // 2022-9-2 内置的Wait工具
  66. STATIC_TOOL m_toolWait;
  67. // 存储标准工具对应的Dll路径,用于快速检索
  68. QHash<QString, QString> m_toolDllPaths;
  69. };