MayaFlux 0.1.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 518 of file ComputeGrammar.hpp.

519 {
520 auto it = std::ranges::find_if(m_rules,
521 [&rule_name](const Rule& rule) { return rule.name == rule_name; });
522
523 if (it != m_rules.end()) {
524 ComputationContext context = it->context;
525 m_rules.erase(it);
526
527 auto& context_rules = m_context_index[context];
528 context_rules.erase(
529 std::remove(context_rules.begin(), context_rules.end(), rule_name),
530 context_rules.end());
531
532 return true;
533 }
534 return false;
535 }
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.