From e04d200d3686146aabe1bd67ef9c71f450ecc406 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Fri, 2 May 2014 00:23:29 +0200 Subject: [PATCH] Allow EvaluateRules() to keep rules for the next iteration. Refs #6105 --- lib/config/applyrule.cpp | 5 +++-- lib/config/applyrule.h | 2 +- lib/config/configitem.cpp | 6 +++--- lib/config/objectrule.cpp | 5 +++-- lib/config/objectrule.h | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/config/applyrule.cpp b/lib/config/applyrule.cpp index a9eba3026..cb73ba229 100644 --- a/lib/config/applyrule.cpp +++ b/lib/config/applyrule.cpp @@ -75,7 +75,7 @@ bool ApplyRule::EvaluateFilter(const Dictionary::Ptr& scope) const return result; } -void ApplyRule::EvaluateRules(void) +void ApplyRule::EvaluateRules(bool clear) { std::set completedTypes; @@ -113,7 +113,8 @@ void ApplyRule::EvaluateRules(void) } } - m_Rules.clear(); + if (clear) + m_Rules.clear(); } void ApplyRule::RegisterType(const String& sourceType, const std::vector& targetTypes, const ApplyRule::Callback& callback) diff --git a/lib/config/applyrule.h b/lib/config/applyrule.h index cdbe4bb3b..8692f718b 100644 --- a/lib/config/applyrule.h +++ b/lib/config/applyrule.h @@ -49,7 +49,7 @@ public: static void AddRule(const String& sourceType, const String& targetType, const String& name, const AExpression::Ptr& expression, const AExpression::Ptr& filter, const DebugInfo& di, const Dictionary::Ptr& scope); - static void EvaluateRules(void); + static void EvaluateRules(bool clear); static void RegisterType(const String& sourceType, const std::vector& targetTypes, const ApplyRule::Callback& callback); static bool IsValidSourceType(const String& sourceType); diff --git a/lib/config/configitem.cpp b/lib/config/configitem.cpp index d236fa807..194fa9c27 100644 --- a/lib/config/configitem.cpp +++ b/lib/config/configitem.cpp @@ -317,13 +317,13 @@ bool ConfigItem::ValidateItems(void) upq.Join(); Log(LogInformation, "config", "Evaluating 'object' rules (step 1)..."); - ObjectRule::EvaluateRules(); + ObjectRule::EvaluateRules(false); Log(LogInformation, "config", "Evaluating 'apply' rules..."); - ApplyRule::EvaluateRules(); + ApplyRule::EvaluateRules(true); Log(LogInformation, "config", "Evaluating 'object' rules (step 2)..."); - ObjectRule::EvaluateRules(); + ObjectRule::EvaluateRules(true); Log(LogInformation, "config", "Validating config items (step 2)..."); diff --git a/lib/config/objectrule.cpp b/lib/config/objectrule.cpp index a6cc0ab2e..c0c7bc0a7 100644 --- a/lib/config/objectrule.cpp +++ b/lib/config/objectrule.cpp @@ -70,7 +70,7 @@ bool ObjectRule::EvaluateFilter(const Dictionary::Ptr& scope) const return result; } -void ObjectRule::EvaluateRules(void) +void ObjectRule::EvaluateRules(bool clear) { std::pair kv; BOOST_FOREACH(kv, m_Callbacks) { @@ -84,7 +84,8 @@ void ObjectRule::EvaluateRules(void) callback(it->second); } - m_Rules.clear(); + if (clear) + m_Rules.clear(); } void ObjectRule::RegisterType(const String& sourceType, const ObjectRule::Callback& callback) diff --git a/lib/config/objectrule.h b/lib/config/objectrule.h index 3f3cbe0b9..530fd35bf 100644 --- a/lib/config/objectrule.h +++ b/lib/config/objectrule.h @@ -48,7 +48,7 @@ public: static void AddRule(const String& sourceType, const String& name, const AExpression::Ptr& expression, const AExpression::Ptr& filter, const DebugInfo& di, const Dictionary::Ptr& scope); - static void EvaluateRules(void); + static void EvaluateRules(bool clear); static void RegisterType(const String& sourceType, const ObjectRule::Callback& callback); static bool IsValidSourceType(const String& sourceType);