• 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_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) {};
UpdateConfig(const ResourceConfiguration & config)34     virtual void UpdateConfig(const ResourceConfiguration& config) {};
35 
GetTheme(int32_t themeId)36     virtual RefPtr<ThemeStyle> GetTheme(int32_t themeId)
37     {
38         return nullptr;
39     };
40 
41     virtual Color GetColor(uint32_t resId) = 0;
42     virtual Dimension GetDimension(uint32_t resId) = 0;
43     virtual std::string GetString(uint32_t resId) = 0;
44     virtual std::vector<std::string> GetStringArray(uint32_t resId) const = 0;
45     virtual double GetDouble(uint32_t resId) = 0;
46     virtual int32_t GetInt(uint32_t resId) = 0;
GetPluralString(uint32_t resId,int quantity)47     virtual std::string GetPluralString(uint32_t resId, int quantity)
48     {
49         return "";
50     }
GetMediaPath(uint32_t resId)51     virtual std::string GetMediaPath(uint32_t resId)
52     {
53         return "";
54     }
GetRawfile(const std::string & fileName)55     virtual std::string GetRawfile(const std::string& fileName)
56     {
57         return "";
58     }
GetBoolean(uint32_t resId)59     virtual bool GetBoolean(uint32_t resId) const
60     {
61         return false;
62     };
GetIntArray(uint32_t resId)63     virtual std::vector<uint32_t> GetIntArray(uint32_t resId) const
64     {
65         return {};
66     };
GetResource(uint32_t resId,std::ostream & dest)67     virtual bool GetResource(uint32_t resId, std::ostream& dest) const
68     {
69         return false;
70     };
GetResource(const std::string & resId,std::ostream & dest)71     virtual bool GetResource(const std::string& resId, std::ostream& dest) const
72     {
73         return false;
74     };
GetIdByName(const std::string & resName,const std::string & resType,uint32_t & resId)75     virtual bool GetIdByName(const std::string& resName, const std::string& resType, uint32_t& resId) const
76     {
77         return false;
78     }
79 };
80 
81 } // namespace OHOS::Ace
82 
83 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_THEME_RESOURCE_ADAPTER_H
84