mirror of
https://github.com/openharmony/bundlemanager_ecological_rule_manager.git
synced 2026-07-01 12:33:50 -04:00
@@ -59,8 +59,6 @@ public:
|
||||
EcologicalRuleCalculator &operator = (const EcologicalRuleCalculator &other) = delete;
|
||||
|
||||
static EcologicalRuleCalculator *GetInstance();
|
||||
bool CalculateOperationExpression(const OHOS::AAFwk::Want &want, const CallerInfo &callerInfo,
|
||||
std::map<std::string, CalculatorResult> &presetCache, std::string &expression);
|
||||
virtual int32_t QueryMatchSceneExperience(const OHOS::AAFwk::Want &want, const CallerInfo &callerInfo,
|
||||
const std::string experienceType, ExperienceRule &experienceRule);
|
||||
|
||||
|
||||
@@ -31,31 +31,6 @@ EcologicalRuleCalculator *EcologicalRuleCalculator::GetInstance()
|
||||
return ecologicalRuleCalculator;
|
||||
}
|
||||
|
||||
bool EcologicalRuleCalculator::CalculateOperationExpression(const OHOS::AAFwk::Want &want, const CallerInfo &callerInfo,
|
||||
std::map<std::string, CalculatorResult> &presetCache, std::string &expression)
|
||||
{
|
||||
BaseExp *rootExp = AnalysisDsl(expression);
|
||||
if (rootExp == nullptr) {
|
||||
LOG_ERROR("[CalculateOperationExpression] AnalysisDsl failed expression is %{public}s.", expression.c_str());
|
||||
return false;
|
||||
}
|
||||
CalculatorResult calculatorResult;
|
||||
try {
|
||||
calculatorResult = rootExp->Interpreter(want, callerInfo, presetCache);
|
||||
} catch (...) {
|
||||
LOG_ERROR("[CalculateOperationExpression]catch exception expression is %{public}s", expression.c_str());
|
||||
delete rootExp;
|
||||
return false;
|
||||
}
|
||||
|
||||
delete rootExp;
|
||||
if (calculatorResult.type != BOOL_TYPE) {
|
||||
return false;
|
||||
} else {
|
||||
return calculatorResult.logicRet;
|
||||
}
|
||||
}
|
||||
|
||||
BaseExp *EcologicalRuleCalculator::AnalysisDsl(const std::string expression)
|
||||
{
|
||||
std::stack<BaseExp *> expStack;
|
||||
|
||||
Reference in New Issue
Block a user