• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 FOUNDATION_ACE_FRAMEWORKS_BASE_RESOURCE_ASSET_MANAGER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_BASE_RESOURCE_ASSET_MANAGER_H
18 
19 #include "base/memory/ace_type.h"
20 #include "base/memory/referenced.h"
21 
22 namespace OHOS::Ace {
23 
24 class Asset : public Referenced {
25 public:
26     ~Asset() override = default;
27 
28     virtual size_t GetSize() const = 0;
29     virtual const uint8_t* GetData() const = 0;
30 };
31 
32 class AssetProvider : public AceType {
33     DECLARE_ACE_TYPE(AssetProvider, AceType);
34 
35 public:
36     virtual std::string GetAssetPath(const std::string& assetName) = 0;
37 
38     virtual void GetAssetList(const std::string& path, std::vector<std::string>& assetList) = 0;
39 
40     virtual bool IsValid() const = 0;
41 };
42 
43 class AssetManager : public AceType {
44     DECLARE_ACE_TYPE(AssetManager, AceType);
45 
46 public:
47     ~AssetManager() override = default;
48 
49     virtual void PushFront(RefPtr<AssetProvider> provider) = 0;
50 
51     virtual void PushBack(RefPtr<AssetProvider> provider) = 0;
52 
53     virtual RefPtr<Asset> GetAsset(const std::string& assetName) = 0;
54 
55     virtual std::string GetAssetPath(const std::string& assetName) = 0;
56 
57     virtual void SetLibPath(const std::string& packagePath) = 0;
58 
59     virtual std::string GetLibPath() const = 0;
60 
61     virtual void GetAssetList(const std::string& path, std::vector<std::string>& assetList) const = 0;
62 };
63 
64 } // namespace OHOS::Ace
65 
66 #endif // FOUNDATION_ACE_FRAMEWORKS_BASE_RESOURCE_ASSET_MANAGER_H
67