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::CtxJson1& fact, ctx::CtxJson1& rule);
31 bool __evaluateRuleCondition(ctx::CtxJson1& fact, ctx::CtxJson1& rule);
32 bool __evaluateItem(ctx::CtxJson1& factItem, ctx::CtxJson1& ruleItem, std::string logicalOp);
33 template <typename T> bool __evaluateData(T factVal, CtxJson1& comparison);
34 template <typename T> bool __evaluateSingleData(T factVal, CtxJson1& comparison, std::string op);
35 template <typename T> bool __evaluateDualData(T factVal, CtxJson1& comparison, std::string op);
36 template <typename T> bool __evaluateMultipleData(T factVal, CtxJson1& comparison, std::string op);
38 ctx::CtxJson1 __getConditionFact(ctx::CtxJson1& fact, ctx::CtxJson1& ruleCond);
40 bool __replaceEventReferences(ctx::CtxJson1& fact, ctx::CtxJson1& rule);
41 void __replaceDataReferences(ctx::CtxJson1 eventFactData, ctx::CtxJson1& ruleComp);
42 void __replaceSingleDataReferences(ctx::CtxJson1& eventFactData, ctx::CtxJson1& ruleComp, std::string& dataKey);
43 void __replaceMultipleDataReferences(ctx::CtxJson1& eventFactData, ctx::CtxJson1& ruleComp, std::string& dataKey);
44 bool __replaceOptionReferences(ctx::CtxJson1 eventFactData, ctx::CtxJson1& ruleOption);
47 static bool evaluateRule(ctx::CtxJson1 rule, ctx::CtxJson1 data);
50 } /* namespace trigger */
53 #endif /* End of _CONTEXT_TRIGGER_RULE_EVALUATOR_H_ */