2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef _CONTEXT_TRIGGER_RULE_EVALUATOR_H_
18 #define _CONTEXT_TRIGGER_RULE_EVALUATOR_H_
30 bool __evaluateRuleEvent(ctx::Json& fact, ctx::Json& rule);
31 bool __evaluateRuleCondition(ctx::Json& fact, ctx::Json& rule);
32 bool __evaluateItem(ctx::Json& factItem, ctx::Json& ruleItem, std::string logicalOp);
33 template <typename T> bool __evaluateData(T factVal, Json& comparison);
34 template <typename T> bool __evaluateSingleData(T factVal, Json& comparison, std::string op);
35 template <typename T> bool __evaluateDualData(T factVal, Json& comparison, std::string op);
36 template <typename T> bool __evaluateMultipleData(T factVal, Json& comparison, std::string op);
38 ctx::Json __getConditionFact(ctx::Json& fact, ctx::Json& ruleCond);
40 bool __replaceEventReferences(ctx::Json& fact, ctx::Json& rule);
41 void __replaceDataReferences(ctx::Json eventFactData, ctx::Json& ruleComp);
42 void __replaceSingleDataReferences(ctx::Json& eventFactData, ctx::Json& ruleComp, std::string& dataKey);
43 void __replaceMultipleDataReferences(ctx::Json& eventFactData, ctx::Json& ruleComp, std::string& dataKey);
44 bool __replaceOptionReferences(ctx::Json eventFactData, ctx::Json& ruleOption);
47 static bool evaluateRule(ctx::Json rule, ctx::Json data);
50 } /* namespace trigger */
53 #endif /* End of _CONTEXT_TRIGGER_RULE_EVALUATOR_H_ */