Change ruleset constants to globals instead of templates
This commit is contained in:
parent
e589e83f24
commit
487c5c5a69
@ -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 <size_t S_MAX_CGROUP_SIZE = 16>
|
||||
struct group_characteristic_t {
|
||||
uint32_t m_factor; // Number of groups generated in succession
|
||||
etl::vector<token_id_t, S_MAX_CGROUP_SIZE> m_token_ids;
|
||||
etl::vector<token_id_t, g_max_cgroup_tokens> m_token_ids;
|
||||
};
|
||||
|
||||
struct marker_t {
|
||||
@ -57,10 +64,9 @@ struct group_t {
|
||||
etl::vector<marker_t, g_max_child_markers> m_child_markers;
|
||||
};
|
||||
|
||||
template <size_t S_MAX_GROUP_WEIGHTS = 8>
|
||||
struct weighted_group_t {
|
||||
etl::vector<group_id_t, S_MAX_GROUP_WEIGHTS> m_groups;
|
||||
etl::vector<uint32_t, S_MAX_GROUP_WEIGHTS> m_weights;
|
||||
etl::vector<group_id_t, g_max_wgroup_weights> m_groups;
|
||||
etl::vector<uint32_t, g_max_wgroup_weights> 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<token_t, S_MAX_TOKENS> m_tokens;
|
||||
etl::vector<group_characteristic_t<S_MAX_CGROUP_TOKENS>, S_MAX_CGROUPS> m_group_characteristics;
|
||||
etl::vector<weighted_group_t<S_MAX_WGROUP_WEIGHTS>, S_MAX_WGROUPS> m_weighted_groups;
|
||||
etl::vector<token_t, g_max_tokens> m_tokens;
|
||||
etl::vector<group_characteristic_t, g_max_groups> m_group_characteristics;
|
||||
etl::vector<weighted_group_t, g_max_wgroups> m_weighted_groups;
|
||||
|
||||
etl::vector<branch_rule_t, S_MAX_BRANCH_RULES> m_branch_rules;
|
||||
etl::vector<mark_rule_t, S_MAX_MARK_RULES> m_mark_rules;
|
||||
etl::vector<branch_rule_t, g_max_branch_rules> m_branch_rules;
|
||||
etl::vector<mark_rule_t, g_max_mark_rules> 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;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user