MayaFlux 0.4.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 522 of file ComputeGrammar.hpp.

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