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>
28 #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(std::string locale);
43 void SetDBType(pkgmgr_common::DBType type);
44 void SetOpType(pkgmgr_common::DBOperationType type);
45 pkgmgr_common::DBOperationType GetOpType();
48 virtual bool Connect();
51 virtual std::vector<std::pair<sqlite3*, uid_t>> GetConnection();
53 const std::string& GetLocale();
54 static std::shared_timed_mutex lock_;
56 std::vector<std::pair<std::string, uid_t>> GetDBPath();
57 pkgmgr_common::DBType db_type_ = pkgmgr_common::DBType::DB_TYPE_NONE;
58 pkgmgr_common::DBOperationType op_type_ =
59 pkgmgr_common::DBOperationType::OPERATION_TYPE_NONE;
63 std::vector<std::pair<sqlite3*, uid_t>> db_handle_list_;
66 } // namespace database
67 } // namespace pkgmgr_server
69 #endif // ABSTRACT_DB_HANDLER_HH_