From 487c5c5a69fc221bff4e258bd743474a535ee03c Mon Sep 17 00:00:00 2001 From: Madeline Busig Date: Tue, 29 Apr 2025 05:50:11 -0700 Subject: [PATCH] Change ruleset constants to globals instead of templates --- include/fractal.hpp | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/include/fractal.hpp b/include/fractal.hpp index efb2234..0c66d27 100644 --- a/include/fractal.hpp +++ b/include/fractal.hpp @@ -9,6 +9,14 @@ namespace fractal { +constexpr size_t g_max_tokens = 16; +constexpr size_t g_max_groups = 8; +constexpr size_t g_max_wgroups = 4; +constexpr size_t g_max_branch_rules = 8; +constexpr size_t g_max_mark_rules = 4; +constexpr size_t g_max_cgroup_tokens = 16; +constexpr size_t g_max_wgroup_weights = 8; + using token_id_t = uint32_t; using group_id_t = uint32_t; using weighted_group_id_t = uint32_t; @@ -26,10 +34,9 @@ struct token_t { mtl::fixed m_value; }; -template struct group_characteristic_t { uint32_t m_factor; // Number of groups generated in succession - etl::vector m_token_ids; + etl::vector m_token_ids; }; struct marker_t { @@ -57,10 +64,9 @@ struct group_t { etl::vector m_child_markers; }; -template struct weighted_group_t { - etl::vector m_groups; - etl::vector m_weights; + etl::vector m_groups; + etl::vector m_weights; uint32_t m_weight_total; // Total needed for random selection // TODO: Control weight additions so m_weight_total = sum(m_weights) is invariant }; @@ -80,29 +86,20 @@ struct mark_rule_t { uint32_t m_tag; }; -template < - size_t S_MAX_TOKENS = 8, - size_t S_MAX_CGROUPS = 8, - size_t S_MAX_WGROUPS = 8, - size_t S_MAX_BRANCH_RULES = 4, - size_t S_MAX_MARK_RULES = 4, - size_t S_MAX_CGROUP_TOKENS = 16, - size_t S_MAX_WGROUP_WEIGHTS = 8 - > class ruleset_t { private: - etl::vector m_tokens; - etl::vector, S_MAX_CGROUPS> m_group_characteristics; - etl::vector, S_MAX_WGROUPS> m_weighted_groups; + etl::vector m_tokens; + etl::vector m_group_characteristics; + etl::vector m_weighted_groups; - etl::vector m_branch_rules; - etl::vector m_mark_rules; + etl::vector m_branch_rules; + etl::vector m_mark_rules; public: /** * @brief Checks if the maximum number of tokens has been reached * - * @ret @c true if the number of tokens in the ruleset equals @c S_MAX_TOKENS, @c false otherwise + * @ret @c true if the number of tokens in the ruleset equals @c g_max_tokens, @c false otherwise */ bool tokens_full() const; @@ -122,7 +119,7 @@ public: /** * @brief Checks if the maximum number of group characteristics has been reached * - * @ret @c true if the number of group characteristics in the ruleset equals @c S_MAX_CGROUPS, @c false otherwise + * @ret @c true if the number of group characteristics in the ruleset equals @c g_max_cgroups, @c false otherwise */ bool group_characteristics_full() const; @@ -142,7 +139,7 @@ public: /** * @brief Checks if the maximum number of weighted groups has been reached * - * @ret @c true if the number of weighted groups in the ruleset equals @c S_MAX_WGROUPS, @c false otherwise + * @ret @c true if the number of weighted groups in the ruleset equals @c g_max_wgroups, @c false otherwise */ bool weighted_groups_full() const; @@ -165,7 +162,7 @@ public: /** * @brief Checks if the maximum number of branch rules has been reached * - * @ret @c true if the number of branch rules in the ruleset equals @c S_MAX_BRANCH_RULES, @c false otherwise + * @ret @c true if the number of branch rules in the ruleset equals @c g_max_branch_rules, @c false otherwise */ bool branch_rules_full() const; @@ -204,7 +201,7 @@ public: /** * @brief Checks if the maximum number of mark rules has been reached * - * @ret @c true if the number of mark rules in the ruleset equals @c S_MAX_MARK_RULES, @c false otherwise + * @ret @c true if the number of mark rules in the ruleset equals @c g_max_mark_rules, @c false otherwise */ bool mark_rules_full() const;