• 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 #ifndef FETCH_RESULT_IMPL_H
16 #define FETCH_RESULT_IMPL_H
17 
18 
19 #include <mutex>
20 
21 #include "album_asset.h"
22 #include "cj_ffi/cj_common_ffi.h"
23 #include "fetch_result.h"
24 #include "photo_accesshelper_utils.h"
25 #include "photo_album_impl.h"
26 #include "photo_asset_impl.h"
27 
28 namespace OHOS {
29 namespace Media {
30 class FfiFetchResultProperty {
31 public:
32     std::shared_ptr<FetchResult<FileAsset>> fetchFileResult_ = nullptr;
33     std::shared_ptr<FetchResult<AlbumAsset>> fetchAlbumResult_ = nullptr;
34     std::shared_ptr<FetchResult<PhotoAlbum>> fetchPhotoAlbumResult_ = nullptr;
35     std::shared_ptr<FetchResult<SmartAlbumAsset>> fetchSmartAlbumResult_ = nullptr;
36     FetchResType fetchResType_;
37 };
38 
39 class FetchResultImpl : public OHOS::FFI::FFIData {
40     DECL_TYPE(FetchResultImpl, OHOS::FFI::FFIData)
41 public:
42     explicit FetchResultImpl(std::unique_ptr<FfiFetchResultProperty> propertyPtr_);
43     std::shared_ptr<FetchResult<FileAsset>> GetFetchFileResultObject();
44     std::shared_ptr<FetchResult<AlbumAsset>> GetFetchAlbumResultObject();
45     std::shared_ptr<FetchResult<PhotoAlbum>> GetFetchPhotoAlbumResultObject();
46     std::shared_ptr<FetchResult<SmartAlbumAsset>> GetFetchSmartAlbumResultObject();
47     int32_t GetCount(int32_t &errCode);
48     bool IsAfterLast(int32_t &errCode);
49     void Close();
50     FetchResultObject GetFirstObject(int32_t &errCode);
51     FetchResultObject GetNextObject(int32_t &errCode);
52     FetchResultObject GetLastObject(int32_t &errCode);
53     FetchResultObject GetObjectAtPosition(int32_t position, int32_t &errCode);
54     CArrayFetchResultObject GetAllObjects(int32_t &errCode);
55 
56 private:
57     std::shared_ptr<FfiFetchResultProperty> propertyPtr = nullptr;
58     std::unique_ptr<FileAsset> fileAsset;
59     std::unique_ptr<AlbumAsset> albumAsset;
60     std::unique_ptr<PhotoAlbum> photoAlbum;
61     std::unique_ptr<SmartAlbumAsset> smartAlbumAsset;
62     std::vector<std::unique_ptr<FileAsset>> fileAssetArray;
63     std::vector<std::unique_ptr<AlbumAsset>> fileAlbumArray;
64     std::vector<std::unique_ptr<PhotoAlbum>> filePhotoAlbumArray;
65     std::vector<std::unique_ptr<SmartAlbumAsset>> fileSmartAlbumArray;
66 };
67 }
68 }
69 #endif