2 * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
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 ABSTRACT_DB_HANDLER_HH_
18 #define ABSTRACT_DB_HANDLER_HH_
20 #include <shared_mutex>
24 #include <sys/types.h>
27 #include "query_parcelable.hh"
30 namespace pkgmgr_server {
34 #define EXPORT_API __attribute__((visibility("default")))
37 class EXPORT_API AbstractDBHandler {
39 AbstractDBHandler(uid_t uid, pid_t pid);
40 virtual ~AbstractDBHandler();
41 virtual int Execute() = 0;
42 void SetLocale(const std::string& locale);
43 void SetDBType(pkgmgr_common::DBType type);
44 void SetOpType(pkgmgr_common::DBOperationType type);
45 pkgmgr_common::DBOperationType GetOpType();
50 std::vector<std::pair<sqlite3*, uid_t>> GetConnection();
51 std::string GetLocale();
52 static std::shared_timed_mutex lock_;
54 std::vector<std::pair<std::string, uid_t>> GetDBPath();
55 pkgmgr_common::DBType db_type_ = pkgmgr_common::DBType::DB_TYPE_NONE;
56 pkgmgr_common::DBOperationType op_type_ =
57 pkgmgr_common::DBOperationType::OPERATION_TYPE_NONE;
61 std::vector<std::pair<sqlite3*, uid_t>> db_handle_list_;
64 } // namespace database
65 } // namespace pkgmgr_server
67 #endif // ABSTRACT_DB_HANDLER_HH_