tizen 2.4 release
[framework/context/context-common.git] / src / context_mgr.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <types_internal.h>
18 #include <json.h>
19 #include <provider_iface.h>
20 #include <context_mgr.h>
21 #include <context_mgr_iface.h>
22
23 static ctx::context_manager_iface *_instance = NULL;
24
25 void ctx::context_manager::set_instance(context_manager_iface* mgr)
26 {
27         _instance = mgr;
28 }
29
30 bool ctx::context_manager::register_provider(const char* subject, ctx::context_provider_info &provider_info)
31 {
32         IF_FAIL_RETURN_TAG(_instance, false, _E, "Not initialized");
33         return _instance->register_provider(subject, provider_info);
34 }
35
36 bool ctx::context_manager::register_trigger_item(const char *subject, int operation, ctx::json attributes, ctx::json options)
37 {
38         IF_FAIL_RETURN_TAG(_instance, false, _E, "Not initialized");
39         return _instance->register_trigger_item(subject, operation, attributes, options);
40 }
41
42 bool ctx::context_manager::publish(const char* subject, ctx::json option, int error, ctx::json data_updated)
43 {
44         IF_FAIL_RETURN_TAG(_instance, false, _E, "Not initialized");
45         return _instance->publish(subject, option, error, data_updated);
46 }
47
48 bool ctx::context_manager::reply_to_read(const char* subject, ctx::json option, int error, ctx::json data_read)
49 {
50         IF_FAIL_RETURN_TAG(_instance, false, _E, "Not initialized");
51         return _instance->reply_to_read(subject, option, error, data_read);
52 }