--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CONTEXT_FACT_TYPES_H__
+#define __CONTEXT_FACT_TYPES_H__
+
+#define CONTEXT_FACT_EVENT "EVENT"
+#define CONTEXT_FACT_CONDITION "CONDITION"
+#define CONTEXT_FACT_NAME "NAME"
+#define CONTEXT_FACT_OPTION "OPTION"
+#define CONTEXT_FACT_DATA "DATA"
+
+#endif //__CONTEXT_FACT_TYPES_H__
#include "rule_evaluator.h"
#include "context_monitor.h"
#include "timer_types.h"
-
-#define CONTEXT_RULE_EVENT "event"
-#define CONTEXT_RULE_CONDITION "condition"
-#define CONTEXT_RULE_NAME "name"
-#define CONTEXT_RULE_OPTION "option"
-#define CONTEXT_RULE_DATA "data"
+#include "context_fact_types.h"
ctx::trigger_rule::trigger_rule()
{
std::string new_str;
int new_val;
- if (result.get(CONTEXT_RULE_EVENT "." CONTEXT_RULE_DATA, event_key.c_str(), &new_str)) {
+ if (result.get(CONTEXT_FACT_EVENT "." CONTEXT_FACT_DATA, event_key.c_str(), &new_str)) {
option.set(NULL, opt_key.c_str(), new_str);
- } else if (result.get(CONTEXT_RULE_EVENT "." CONTEXT_RULE_DATA, event_key.c_str(), &new_val)) {
+ } else if (result.get(CONTEXT_FACT_EVENT "." CONTEXT_FACT_DATA, event_key.c_str(), &new_val)) {
option.set(NULL, opt_key.c_str(), new_val);
} else {
_W("Failed to find '%s' in event data", event_key.c_str());
_D("Rule%d received event data", id);
// Set event data
- result.set(CONTEXT_RULE_EVENT, CONTEXT_RULE_NAME, name);
- result.set(CONTEXT_RULE_EVENT, CONTEXT_RULE_OPTION, option);
- result.set(CONTEXT_RULE_EVENT, CONTEXT_RULE_DATA, data);
+ result.set(CONTEXT_FACT_EVENT, CONTEXT_FACT_NAME, name);
+ result.set(CONTEXT_FACT_EVENT, CONTEXT_FACT_OPTION, option);
+ result.set(CONTEXT_FACT_EVENT, CONTEXT_FACT_DATA, data);
if (condition.size() == 0) {
on_context_data_prepared();
// Set condition data
ctx::json item;
- item.set(NULL, CONTEXT_RULE_NAME, name);
- item.set(NULL, CONTEXT_RULE_OPTION, option);
- item.set(NULL, CONTEXT_RULE_DATA, data);
- result.array_append(NULL, CONTEXT_RULE_CONDITION, item);
+ item.set(NULL, CONTEXT_FACT_NAME, name);
+ item.set(NULL, CONTEXT_FACT_OPTION, option);
+ item.set(NULL, CONTEXT_FACT_DATA, data);
+ result.array_append(NULL, CONTEXT_FACT_CONDITION, item);
- if (result.array_get_size(NULL, CONTEXT_RULE_CONDITION) == (int) condition.size()) {
+ if (result.array_get_size(NULL, CONTEXT_FACT_CONDITION) == (int) condition.size()) {
on_context_data_prepared();
}
}