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_MANAGER_IMPL_H__
18 #define __CONTEXT_MANAGER_IMPL_H__
23 #include <context_mgr.h>
24 #include <context_mgr_iface.h>
27 #define TRIGGER_CLIENT_NAME "TRIGGER"
31 class context_manager_impl : public context_manager_iface {
33 typedef std::list<request_info*> request_list_t;
35 context_manager_impl();
36 ~context_manager_impl();
41 void assign_request(ctx::request_info *request);
42 bool is_supported(const char *subject);
43 bool is_allowed(const char *client, const char *subject);
44 bool pop_trigger_item(std::string &subject, int &operation, ctx::json &attributes, ctx::json &options);
46 /* From the interface class */
47 bool register_provider(const char *subject, context_provider_info &provider_info);
48 bool register_trigger_item(const char *subject, int operation, ctx::json attributes, ctx::json options);
49 bool publish(const char *subject, ctx::json &option, int error, ctx::json &data_updated);
50 bool reply_to_read(const char *subject, ctx::json &option, int error, ctx::json &data_read);
53 typedef std::map<std::string, context_provider_info> provider_map_t;
55 request_list_t subscribe_request_list;
56 request_list_t read_request_list;
57 provider_map_t provider_map;
59 void subscribe(request_info *request);
60 void unsubscribe(request_info *request);
61 void read(request_info *request);
62 void write(request_info *request);
63 void is_supported(request_info *request);
65 context_provider_iface *get_provider(request_info *request);
67 static gboolean thread_switcher(gpointer data);
68 bool _publish(const char *subject, ctx::json option, int error, ctx::json data_updated);
69 bool _reply_to_read(const char *subject, ctx::json option, int error, ctx::json data_read);
71 request_list_t::iterator find_request(request_list_t& r_list, std::string subject, json& option);
72 request_list_t::iterator find_request(request_list_t& r_list, std::string client, int req_id);
73 request_list_t::iterator find_request(request_list_t::iterator begin, request_list_t::iterator end, std::string subject, json& option);
75 }; /* class context_manager_impl */
79 #endif /* End of __CONTEXT_MANAGER_IMPL_H__ */