• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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_CORE_COMPONENTS_THEME_RESOURCE_ADAPTER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_THEME_RESOURCE_ADAPTER_H
18 
19 #include "base/utils/resource_configuration.h"
20 #include "core/components/theme/theme_style.h"
21 
22 namespace OHOS::Ace {
23 
24 class ResourceAdapter : public virtual AceType {
25     DECLARE_ACE_TYPE(ResourceAdapter, AceType);
26 
27 public:
28     ResourceAdapter() = default;
29     ~ResourceAdapter() override = default;
30 
31     static RefPtr<ResourceAdapter> Create();
32 
Init(const ResourceInfo & resourceInfo)33     virtual void Init(const ResourceInfo& resourceInfo) {}
Reload()34     virtual void Reload() {}
UpdateConfig(const ResourceConfiguration & config)35     virtual void UpdateConfig(const ResourceConfiguration& config) {}
36 
GetTheme(int32_t themeId)37     virtual RefPtr<ThemeStyle> GetTheme(int32_t themeId)
38     {
39         return nullptr;
40     };
41 
42     virtual Color GetColor(uint32_t resId) = 0;
GetColorByName(const std::string & resName)43     virtual Color GetColorByName(const std::string& resName)
44     {
45         return {};
46     }
47     virtual Dimension GetDimension(uint32_t resId) = 0;
GetDimensionByName(const std::string & resName)48     virtual Dimension GetDimensionByName(const std::string& resName)
49     {
50         return {};
51     }
52     virtual std::string GetString(uint32_t resId) = 0;
GetStringByName(const std::string & resName)53     virtual std::string GetStringByName(const std::string& resName)
54     {
55         return "";
56     }
57     virtual std::vector<std::string> GetStringArray(uint32_t resId) const = 0;
GetStringArrayByName(const std::string & resName)58     virtual std::vector<std::string> GetStringArrayByName(const std::string& resName) const
59     {
60         return {};
61     }
62     virtual double GetDouble(uint32_t resId) = 0;
GetDoubleByName(const std::string & resName)63     virtual double GetDoubleByName(const std::string& resName)
64     {
65         return 0.0;
66     }
67     virtual int32_t GetInt(uint32_t resId) = 0;
GetIntByName(const std::string & resName)68     virtual int32_t GetIntByName(const std::string& resName)
69     {
70         return 0;
71     }
GetPluralString(uint32_t resId,int quantity)72     virtual std::string GetPluralString(uint32_t resId, int quantity)
73     {
74         return "";
75     }
GetPluralStringByName(const std::string & resName,int quantity)76     virtual std::string GetPluralStringByName(const std::string& resName, int quantity)
77     {
78         return "";
79     }
GetMediaPath(uint32_t resId)80     virtual std::string GetMediaPath(uint32_t resId)
81     {
82         return "";
83     }
GetMediaPathByName(const std::string & resName)84     virtual std::string GetMediaPathByName(const std::string& resName)
85     {
86         return "";
87     }
GetRawfile(const std::string & fileName)88     virtual std::string GetRawfile(const std::string& fileName)
89     {
90         return "";
91     }
GetRawFileData(const std::string & rawFile,size_t & len,std::unique_ptr<uint8_t[]> & dest)92     virtual bool GetRawFileData(const std::string& rawFile, size_t& len, std::unique_ptr<uint8_t[]> &dest)
93     {
94         return false;
95     }
GetMediaData(uint32_t resId,size_t & len,std::unique_ptr<uint8_t[]> & dest)96     virtual bool GetMediaData(uint32_t resId, size_t& len, std::unique_ptr<uint8_t[]> &dest)
97     {
98         return false;
99     }
GetMediaData(const std::string & resName,size_t & len,std::unique_ptr<uint8_t[]> & dest)100     virtual bool GetMediaData(const std::string& resName, size_t& len, std::unique_ptr<uint8_t[]> &dest)
101     {
102         return false;
103     }
GetBoolean(uint32_t resId)104     virtual bool GetBoolean(uint32_t resId) const
105     {
106         return false;
107     };
GetBooleanByName(const std::string & resName)108     virtual bool GetBooleanByName(const std::string& resName) const
109     {
110         return false;
111     }
GetIntArray(uint32_t resId)112     virtual std::vector<uint32_t> GetIntArray(uint32_t resId) const
113     {
114         return {};
115     };
GetIntArrayByName(const std::string & resName)116     virtual std::vector<uint32_t> GetIntArrayByName(const std::string& resName) const
117     {
118         return {};
119     }
GetResource(uint32_t resId,std::ostream & dest)120     virtual bool GetResource(uint32_t resId, std::ostream& dest) const
121     {
122         return false;
123     };
GetResource(const std::string & resId,std::ostream & dest)124     virtual bool GetResource(const std::string& resId, std::ostream& dest) const
125     {
126         return false;
127     };
GetIdByName(const std::string & resName,const std::string & resType,uint32_t & resId)128     virtual bool GetIdByName(const std::string& resName, const std::string& resType, uint32_t& resId) const
129     {
130         return false;
131     }
132 
UpdateResourceManager(const std::string & bundleName,const std::string & moduleName)133     virtual void UpdateResourceManager(const std::string& bundleName, const std::string& moduleName) {}
134 };
135 
136 } // namespace OHOS::Ace
137 
138 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_THEME_RESOURCE_ADAPTER_H
139