BlockFilter.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. #pragma once
  2. #include <Array.h>
  3. #include "TypeRegistry.h"
  4. class Block;
  5. class BlockFilter : public Framework::ReferenceCounter
  6. {
  7. public:
  8. BlockFilter();
  9. virtual bool test(const Block* zBlock) = 0;
  10. };
  11. class BlockFilterAnd : public BlockFilter
  12. {
  13. private:
  14. Framework::RCArray<BlockFilter> filters;
  15. public:
  16. BlockFilterAnd();
  17. bool test(const Block* zBlock) override;
  18. void addFilter(BlockFilter* filter);
  19. Framework::RCArray<BlockFilter> getFilters() const;
  20. };
  21. class BlockFilterAndFactory : public SubTypeFactory<BlockFilter, BlockFilterAnd>
  22. {
  23. public:
  24. BlockFilterAndFactory();
  25. BlockFilterAnd* createValue(
  26. Framework::JSON::JSONObject* zJson) const override;
  27. void fromJson(BlockFilterAnd* zResult,
  28. Framework::JSON::JSONObject* zJson) const override;
  29. void toJson(BlockFilterAnd* zObject,
  30. Framework::JSON::JSONObject* zResult) const override;
  31. JSONObjectValidationBuilder* addToValidator(
  32. JSONObjectValidationBuilder* builder) const override;
  33. Framework::Text getTypeToken() const override;
  34. };
  35. class BlockFilterOr : public BlockFilter
  36. {
  37. private:
  38. Framework::RCArray<BlockFilter> filters;
  39. public:
  40. BlockFilterOr();
  41. bool test(const Block* zBlock) override;
  42. void addFilter(BlockFilter* filter);
  43. Framework::RCArray<BlockFilter> getFilters() const;
  44. };
  45. class BlockFilterOrFactory : public SubTypeFactory<BlockFilter, BlockFilterOr>
  46. {
  47. public:
  48. BlockFilterOrFactory();
  49. BlockFilterOr* createValue(
  50. Framework::JSON::JSONObject* zJson) const override;
  51. void fromJson(BlockFilterOr* zResult,
  52. Framework::JSON::JSONObject* zJson) const override;
  53. void toJson(BlockFilterOr* zObject,
  54. Framework::JSON::JSONObject* zResult) const override;
  55. JSONObjectValidationBuilder* addToValidator(
  56. JSONObjectValidationBuilder* builder) const override;
  57. Framework::Text getTypeToken() const override;
  58. };
  59. class BlockFilterNot : public BlockFilter
  60. {
  61. private:
  62. BlockFilter* filter;
  63. public:
  64. BlockFilterNot();
  65. ~BlockFilterNot();
  66. bool test(const Block* zBlock) override;
  67. void setFilter(BlockFilter* filter);
  68. BlockFilter* zFilter() const;
  69. };
  70. class BlockFilterNotFactory : public SubTypeFactory<BlockFilter, BlockFilterNot>
  71. {
  72. public:
  73. BlockFilterNotFactory();
  74. BlockFilterNot* createValue(
  75. Framework::JSON::JSONObject* zJson) const override;
  76. void fromJson(BlockFilterNot* zResult,
  77. Framework::JSON::JSONObject* zJson) const override;
  78. void toJson(BlockFilterNot* zObject,
  79. Framework::JSON::JSONObject* zResult) const override;
  80. JSONObjectValidationBuilder* addToValidator(
  81. JSONObjectValidationBuilder* builder) const override;
  82. Framework::Text getTypeToken() const override;
  83. };
  84. class BlockFilterBlockType : public BlockFilter
  85. {
  86. private:
  87. Framework::Array<int> blockTypeIds;
  88. public:
  89. BlockFilterBlockType();
  90. bool test(const Block* zBlock) override;
  91. void addBlockTypeId(int blockTypeId);
  92. const Framework::Array<int>& getBlockTypeIds() const;
  93. };
  94. class BlockFilterBlockTypeFactory
  95. : public SubTypeFactory<BlockFilter, BlockFilterBlockType>
  96. {
  97. public:
  98. BlockFilterBlockTypeFactory();
  99. BlockFilterBlockType* createValue(
  100. Framework::JSON::JSONObject* zJson) const override;
  101. void fromJson(BlockFilterBlockType* zResult,
  102. Framework::JSON::JSONObject* zJson) const override;
  103. void toJson(BlockFilterBlockType* zObject,
  104. Framework::JSON::JSONObject* zResult) const override;
  105. JSONObjectValidationBuilder* addToValidator(
  106. JSONObjectValidationBuilder* builder) const override;
  107. Framework::Text getTypeToken() const override;
  108. };
  109. class BlockFilterTypeGroup : public BlockFilter
  110. {
  111. private:
  112. Framework::RCArray<Framework::Text> groupNames;
  113. public:
  114. BlockFilterTypeGroup();
  115. bool test(const Block* zBlock) override;
  116. void addGroupName(const Framework::Text groupName);
  117. const Framework::RCArray<Framework::Text>& getGroupNames() const;
  118. };
  119. class BlockFilterTypeGroupFactory
  120. : public SubTypeFactory<BlockFilter, BlockFilterTypeGroup>
  121. {
  122. public:
  123. BlockFilterTypeGroupFactory();
  124. BlockFilterTypeGroup* createValue(
  125. Framework::JSON::JSONObject* zJson) const override;
  126. void fromJson(BlockFilterTypeGroup* zResult,
  127. Framework::JSON::JSONObject* zJson) const override;
  128. void toJson(BlockFilterTypeGroup* zObject,
  129. Framework::JSON::JSONObject* zResult) const override;
  130. JSONObjectValidationBuilder* addToValidator(
  131. JSONObjectValidationBuilder* builder) const override;
  132. Framework::Text getTypeToken() const override;
  133. };
  134. class BlockFilterMaxHardness : public BlockFilter
  135. {
  136. private:
  137. float maxHardness;
  138. public:
  139. BlockFilterMaxHardness();
  140. bool test(const Block* zBlock) override;
  141. void setMaxHardness(float maxHardness);
  142. float getMaxHardness() const;
  143. };
  144. class BlockFilterMaxHardnessFactory
  145. : public SubTypeFactory<BlockFilter, BlockFilterMaxHardness>
  146. {
  147. public:
  148. BlockFilterMaxHardnessFactory();
  149. BlockFilterMaxHardness* createValue(
  150. Framework::JSON::JSONObject* zJson) const override;
  151. void fromJson(BlockFilterMaxHardness* zResult,
  152. Framework::JSON::JSONObject* zJson) const override;
  153. void toJson(BlockFilterMaxHardness* zObject,
  154. Framework::JSON::JSONObject* zResult) const override;
  155. JSONObjectValidationBuilder* addToValidator(
  156. JSONObjectValidationBuilder* builder) const override;
  157. Framework::Text getTypeToken() const override;
  158. };
  159. class BlockFilterMinHardness : public BlockFilter
  160. {
  161. private:
  162. float minHardness;
  163. public:
  164. BlockFilterMinHardness();
  165. bool test(const Block* zBlock) override;
  166. void setMinHardness(float minHardness);
  167. float getMinHardness() const;
  168. };
  169. class BlockFilterMinHardnessFactory
  170. : public SubTypeFactory<BlockFilter, BlockFilterMinHardness>
  171. {
  172. public:
  173. BlockFilterMinHardnessFactory();
  174. BlockFilterMinHardness* createValue(
  175. Framework::JSON::JSONObject* zJson) const override;
  176. void fromJson(BlockFilterMinHardness* zResult,
  177. Framework::JSON::JSONObject* zJson) const override;
  178. void toJson(BlockFilterMinHardness* zObject,
  179. Framework::JSON::JSONObject* zResult) const override;
  180. JSONObjectValidationBuilder* addToValidator(
  181. JSONObjectValidationBuilder* builder) const override;
  182. Framework::Text getTypeToken() const override;
  183. };
  184. class BlockFilterMaxHeat : public BlockFilter
  185. {
  186. private:
  187. float maxHeat;
  188. public:
  189. BlockFilterMaxHeat();
  190. bool test(const Block* zBlock) override;
  191. void setMaxHeat(float maxHeat);
  192. float getMaxHeat() const;
  193. };
  194. class BlockFilterMaxHeatFactory
  195. : public SubTypeFactory<BlockFilter, BlockFilterMaxHeat>
  196. {
  197. public:
  198. BlockFilterMaxHeatFactory();
  199. BlockFilterMaxHeat* createValue(
  200. Framework::JSON::JSONObject* zJson) const override;
  201. void fromJson(BlockFilterMaxHeat* zResult,
  202. Framework::JSON::JSONObject* zJson) const override;
  203. void toJson(BlockFilterMaxHeat* zObject,
  204. Framework::JSON::JSONObject* zResult) const override;
  205. JSONObjectValidationBuilder* addToValidator(
  206. JSONObjectValidationBuilder* builder) const override;
  207. Framework::Text getTypeToken() const override;
  208. };