MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ remove_rule()

bool MayaFlux::Yantra::ComputationGrammar::remove_rule ( const std::string &  rule_name)
inline

Remove a rule by name.

Parameters
rule_nameName of rule to remove
Returns
True if rule was removed, false if not found

Removes the rule from both the main rule list and the context index. This is useful for dynamic rule management and grammar updates.

Definition at line 567 of file ComputeGrammar.hpp.

568 {
569 auto it = std::ranges::find_if(m_rules,
570 [&rule_name](const Rule& rule) { return rule.name == rule_name; });
571
572 if (it != m_rules.end()) {
573 ComputationContext context = it->context;
574 m_rules.erase(it);
575
576 auto& context_rules = m_context_index[context];
577 std::erase_if(context_rules,
578 [&](const std::string& name) {
579 return name == rule_name;
580 });
581
582 return true;
583 }
584 return false;
585 }
std::unordered_map< ComputationContext, std::vector< std::string > > m_context_index
Index of rule names by context for fast lookup.
std::vector< Rule > m_rules
All rules sorted by priority (highest first)
ComputationContext
Defines the computational contexts in which rules can be applied.

References MayaFlux::Yantra::ComputationGrammar::Rule::name.