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 #include <types_internal.h>
19 #include <db_listener_iface.h>
21 #include <db_mgr_iface.h>
23 static ctx::db_manager_iface *_instance = NULL;
25 void ctx::db_manager::set_instance(ctx::db_manager_iface* mgr)
30 bool ctx::db_manager::create_table(unsigned int query_id, const char* table_name, const char* columns, const char* option, db_listener_iface* listener)
32 IF_FAIL_RETURN_TAG(_instance, false, _E, "Not initialized");
33 return _instance->create_table(query_id, table_name, columns, option, listener);
36 bool ctx::db_manager::insert(unsigned int query_id, const char* table_name, json& record, db_listener_iface* listener)
38 IF_FAIL_RETURN_TAG(_instance, false, _E, "Not initialized");
39 return _instance->insert(query_id, table_name, record, listener);
42 bool ctx::db_manager::execute(unsigned int query_id, const char* query, db_listener_iface* listener)
44 IF_FAIL_RETURN_TAG(_instance, false, _E, "Not initialized");
45 return _instance->execute(query_id, query, listener);
48 bool ctx::db_manager::insert_sync(const char* table_name, json& record, int64_t* row_id)
50 IF_FAIL_RETURN_TAG(_instance, false, _E, "Not initialized");
51 return _instance->insert_sync(table_name, record, row_id);
54 bool ctx::db_manager::execute_sync(const char* query, std::vector<json>* records)
56 IF_FAIL_RETURN_TAG(_instance, false, _E, "Not initialized");
57 return _instance->execute_sync(query, records);