• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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_MEDIALIBRARY_ALBUM_DATA_MANAGER_H
17 #define OHOS_MEDIALIBRARY_ALBUM_DATA_MANAGER_H
18 
19 #include <string>
20 #include <vector>
21 #include <unordered_map>
22 
23 #include "accurate_refresh_data_manager.h"
24 #include "abs_rdb_predicates.h"
25 #include "result_set.h"
26 
27 #include "album_change_info.h"
28 
29 namespace OHOS {
30 namespace Media::AccurateRefresh {
31 #define EXPORT __attribute__ ((visibility ("default")))
32 
33 class EXPORT AlbumDataManager : public AccurateRefreshDataManager<AlbumChangeInfo, AlbumChangeData> {
34 public:
AlbumDataManager()35     AlbumDataManager() : AlbumDataManager(nullptr) {}
AlbumDataManager(std::shared_ptr<TransactionOperations> trans)36     AlbumDataManager(std::shared_ptr<TransactionOperations> trans)
37         : AccurateRefreshDataManager<AlbumChangeInfo, AlbumChangeData>(trans) {}
~AlbumDataManager()38     virtual ~AlbumDataManager() {}
39     // 增删场景下初始化数据
40     int32_t InitAlbumInfos(const std::vector<int> &albumIds);
41     int32_t UpdateModifiedDatas() override;
42     int32_t PostProcessModifiedDatas(const std::vector<int32_t> &keys) override;
43     std::unordered_map<int32_t, AlbumChangeInfo> GetInitAlbumInfos();
44     std::vector<int32_t> GetInitKeys() override;
45     static std::vector<AlbumChangeData> GetAlbumDatasFromAddAlbum(const std::vector<std::string> &albumIdsStr);
46 
47 private:
48     int32_t GetChangeInfoKey(const AlbumChangeInfo &changeInfo) override;
49     std::vector<AlbumChangeInfo> GetInfoByKeys(const std::vector<int32_t> &albumIds) override;
50     std::vector<AlbumChangeInfo> GetInfosByPredicates(const NativeRdb::AbsRdbPredicates &predicates) override;
51     std::vector<AlbumChangeInfo> GetInfosByResult(
52         const std::shared_ptr<NativeRdb::ResultSet> &resultSet) override;
53 
54     std::vector<AlbumChangeInfo> GetAlbumInfos(const std::vector<int32_t> &albumIds,
55         const std::vector<std::string> systemTypes = {});
56     PhotoAssetChangeInfo GetPhotoAssetInfo(int32_t fileId);
57 };
58 
59 } // namespace Media
60 } // namespace OHOS
61 
62 #endif