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_MANAGER_IMPL_H__
18 #define __CONTEXT_MANAGER_IMPL_H__
23 #include <context_mgr_iface.h>
26 #define TRIGGER_CLIENT_NAME "TRIGGER"
30 class context_manager_impl : public context_manager_iface {
32 typedef std::list<request_info*> request_list_t;
34 context_manager_impl();
35 ~context_manager_impl();
40 void assign_request(ctx::request_info* request);
41 bool is_supported(const char* subject, const char* zone);
43 // From the interface class
44 bool register_provider(const char* subject, ctx::context_provider_iface* cp);
45 bool publish(const char* subject, ctx::json& option, int error, ctx::json& data_updated, const char* zone);
46 bool reply_to_read(const char* subject, ctx::json& option, int error, ctx::json& data_read, const char* zone);
50 typedef std::vector<context_provider_iface*> provider_list_t;
51 typedef std::map<std::string, context_provider_iface*> subject_provider_map_t;
53 provider_list_t provider_list;
54 request_list_t subscribe_request_list;
55 request_list_t read_request_list;
56 subject_provider_map_t subject_provider_map;
58 void load_provider(ctx::context_provider_iface* provider);
60 void subscribe(request_info* request, context_provider_iface* provider);
61 void unsubscribe(request_info* request);
62 void read(request_info* request, context_provider_iface* provider);
63 void write(request_info* request, context_provider_iface* provider);
65 bool check_permission(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, const char* zone);
69 bool _reply_to_read(const char* subject, ctx::json option, int error, ctx::json data_read, const char* zone);
71 request_list_t::iterator find_request(request_list_t& r_list, std::string subject, json& option, const char* zone);
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, const char* zone);
75 }; /* class context_manager_impl */
79 #endif /* End of __CONTEXT_MANAGER_IMPL_H__ */