2 * Copyright (c) 2014 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_CONTEXT_TRIGGER_H__
18 #define __CONTEXT_CONTEXT_TRIGGER_H__
20 #include <event_driven.h>
21 #include "../request.h"
29 class context_manager_impl;
30 class context_trigger : public event_driven_thread {
35 bool init(ctx::context_manager_impl* mgr);
38 bool assign_request(ctx::request_info* request);
39 void push_fact(int req_id, int error, const char* subject, ctx::json& option, ctx::json& data, const char* zone);
40 bool publish(int rule_id, int error, ctx::json data);
41 bool _publish(int rule_id, int error, ctx::json data);
46 ETYPE_REQUEST = 1, // A request received from a client
47 ETYPE_FACT, // A context fact received from a CA
48 ETYPE_INITIALIZE, // Initialization
51 ctx::fact_reader *_reader;
53 void on_thread_event_popped(int type, void* data);
54 void delete_thread_event(int type, void* data);
56 void process_request(ctx::request_info* request);
57 void process_fact(ctx::context_fact* fact);
58 void process_initialize(void);
60 void add_rule(ctx::request_info* request);
61 void remove_rule(ctx::request_info* request);
62 void enable_rule(ctx::request_info* request);
63 void disable_rule(ctx::request_info* request);
64 void get_rule_by_id(ctx::request_info* request);
65 void get_rule_ids(ctx::request_info* request);
67 ctx::rule_manager* rule_mgr;
72 #endif /* End of __CONTEXT_CONTEXT_TRIGGER_H__ */