• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_DP_DEVICE_ICON_INFO_DAO_H
17 #define OHOS_DP_DEVICE_ICON_INFO_DAO_H
18 
19 #include <memory>
20 #include <mutex>
21 #include <string>
22 #include <vector>
23 
24 #include "device_icon_info.h"
25 #include "device_icon_info_filter_options.h"
26 #include "profile_data_rdb_adapter.h"
27 #include "single_instance.h"
28 #include "values_bucket.h"
29 
30 namespace OHOS {
31 namespace DistributedDeviceProfile {
32 using namespace OHOS::NativeRdb;
33 
34 class DeviceIconInfoDao {
35     DECLARE_SINGLE_INSTANCE(DeviceIconInfoDao);
36 
37 public:
38     int32_t Init();
39     int32_t UnInit();
40     int32_t PutDeviceIconInfo(const DeviceIconInfo& deviceIconInfo);
41     int32_t GetDeviceIconInfos(const DeviceIconInfoFilterOptions& filterOptions,
42         std::vector<DeviceIconInfo>& deviceIconInfos);
43     int32_t DeleteDeviceIconInfo(const DeviceIconInfo& deviceIconInfo);
44     int32_t UpdateDeviceIconInfo(const DeviceIconInfo& deviceIconInfo);
45     int32_t CreateTable();
46     int32_t CreateIndex();
47     bool CreateQuerySqlAndCondition(const DeviceIconInfoFilterOptions& filterOptions,
48         std::string& sql, std::vector<ValueObject>& condition);
49     int32_t DeviceIconInfoToEntries(const DeviceIconInfo& deviceIconInfo, ValuesBucket& values);
50     int32_t ConvertToDeviceIconInfo(std::shared_ptr<ResultSet> resultSet, DeviceIconInfo& deviceIconInfo);
51 private:
52     std::mutex rdbMutex_;
53 };
54 } // DistributedDeviceProfile
55 } // OHOS
56 #endif // OHOS_DP_DEVICE_ICON_INFO_DAO_H
57