ComponentBase.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /**
  2. * @file ComponentBase.h
  3. * @brief 组件基类头文件
  4. * @author FastCAE研发小组(fastcae@diso.cn)
  5. * @version 2.5.0
  6. * @date 2022-03-28 14:56
  7. * @copyright Copyright (c) Since 2020 青岛数智船海科技有限公司 All rights reserved.
  8. *
  9. * ============================================================================
  10. * Program: FastCAE
  11. *
  12. * Copyright (c) Since 2020 青岛数智船海科技有限公司 All rights reserved.
  13. * See License or http://www.fastcae.com/ for details.
  14. *
  15. * BSD 3-Clause License
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  18. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. * DISCLAIMED.
  21. * ==================================================================================
  22. */
  23. #ifndef _COMPONENTBASE_H_
  24. #define _COMPONENTBASE_H_
  25. #include "DataPropertyAPI.h"
  26. #include "DataBase.h"
  27. namespace DataProperty
  28. {
  29. /**
  30. * @brief 组件类型枚举值
  31. * @since 2.5.0
  32. */
  33. enum ComponentType
  34. {
  35. MESH = 1, ///< 网格组件
  36. GEOMETRY ///< 几何组件
  37. };
  38. /**
  39. * @brief 组件基类
  40. * @since 2.5.0
  41. */
  42. class DATAPROPERTYAPI ComponentBase : public DataBase
  43. {
  44. public:
  45. /**
  46. * @brief 构造函数
  47. * @param type 组件类型
  48. * @since 2.5.0
  49. */
  50. ComponentBase(ComponentType type);
  51. /**
  52. * @brief 析构函数
  53. * @since 2.5.0
  54. */
  55. virtual ~ComponentBase();
  56. /**
  57. * @brief 获取组件类型
  58. * @return ComponentType 返回组件类型
  59. * @since 2.5.0
  60. */
  61. ComponentType getComponentType();
  62. /**
  63. * @brief 设置组件id
  64. * @param id 组件id
  65. * @since 2.5.0
  66. */
  67. void setID(int id);
  68. /**
  69. * @brief 获取最大id
  70. * @return int 最大组件id
  71. * @since 2.5.0
  72. */
  73. static int getMaxID();
  74. /**
  75. * @brief 重置组件id
  76. * @since 2.5.0
  77. */
  78. static void resetMaxID();
  79. /**
  80. * @brief 通过id获取组件类型
  81. * @param id
  82. * @return ComponentType 返回组件类型
  83. * @since 2.5.0
  84. */
  85. static ComponentType getComponentTypeByID(int id);
  86. /**
  87. * @brief 组件类型转字符串
  88. * @param cpType 要转换的组件类型
  89. * @return QString 返回转换后的字符串
  90. * @since 2.5.0
  91. */
  92. static QString componentTypeToString(ComponentType cpType);
  93. /**
  94. * @brief 字符串转组件类型
  95. * @param sType 要转换的字符串
  96. * @return ComponentType 返回转换后的组件类型
  97. * @since 2.5.0
  98. */
  99. static ComponentType stringToComponentType(QString sType);
  100. private:
  101. /**
  102. * @brief 组件id与类型的对应哈希表
  103. * @since 2.5.0
  104. */
  105. static QHash<int, ComponentType> IDType;
  106. /**
  107. * @brief 组件当前最大ID值
  108. * @since 2.5.0
  109. */
  110. static int currMaxID;
  111. /**
  112. * @brief 组件类型
  113. * @since 2.5.0
  114. */
  115. ComponentType _type;
  116. };
  117. }
  118. #endif