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_STATS_DB_HANDLE_BASE_H__
18 #define __CONTEXT_STATS_DB_HANDLE_BASE_H__
22 #include <db_listener_iface.h>
25 class stats_db_handle_base : public db_listener_iface {
28 std::string req_subject;
30 stats_db_handle_base(const char* zone);
31 ~stats_db_handle_base();
33 std::string create_where_clause(ctx::json filter);
34 std::string create_sql_peak_time(ctx::json filter, const char* table_name, std::string where_clause);
35 std::string create_sql_common_setting(ctx::json filter, const char* table_name, std::string where_clause);
37 bool execute_query(const char* subject, ctx::json filter, const char* query);
38 static int generate_qid();
44 void json_vector_to_array(std::vector<json> &vec_json, ctx::json &json_result);
46 void on_creation_result_received(unsigned int query_id, int error);
47 void on_insertion_result_received(unsigned int query_id, int error, int64_t row_id);
48 void on_query_result_received(unsigned int query_id, int error, std::vector<json>& records);
52 #endif /* __CONTEXT_STATS_DB_HANDLE_BASE_H__ */