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 FOUNDATION_ACE_INTERFACE_INNERAPI_BASE_RESOURCE_H 17 #define FOUNDATION_ACE_INTERFACE_INNERAPI_BASE_RESOURCE_H 18 19 #include <cstdint> 20 #include <optional> 21 #include <string> 22 #include <vector> 23 24 namespace OHOS { 25 namespace Ace { 26 namespace Drawable { 27 enum class ResourceObjectParamType { NONE, INT, STRING, FLOAT }; 28 29 struct ResourceObjectParams { 30 std::optional<std::string> value; 31 ResourceObjectParamType type = ResourceObjectParamType::NONE; 32 }; 33 34 class Resource { 35 public: 36 Resource() = default; Resource(int32_t id,int32_t type,const std::vector<ResourceObjectParams> & params,const std::string & bundleName,const std::string & moduleName)37 Resource(int32_t id, int32_t type, const std::vector<ResourceObjectParams>& params, 38 const std::string& bundleName, const std::string& moduleName) 39 : id_(id), type_(type), params_(params), bundleName_(bundleName), moduleName_(moduleName) {}; 40 ~Resource() = default; 41 GetId()42 int32_t GetId() const 43 { 44 return id_; 45 } 46 GetType()47 int32_t GetType() const 48 { 49 return type_; 50 } 51 GetParams()52 std::vector<ResourceObjectParams> GetParams() const 53 { 54 return params_; 55 } 56 GetBundleName()57 std::string GetBundleName() const 58 { 59 return bundleName_; 60 } 61 GetModuleName()62 std::string GetModuleName() const 63 { 64 return moduleName_; 65 } 66 ToString()67 std::string ToString() const 68 { 69 std::string result; 70 result.append("id:"); 71 result.append(std::to_string(id_)); 72 result.append("type:"); 73 result.append(std::to_string(type_)); 74 result.append("bundleName:"); 75 result.append(bundleName_); 76 result.append("moduleName:"); 77 result.append(moduleName_); 78 return result; 79 } 80 81 private: 82 int32_t id_; 83 int32_t type_; 84 std::vector<ResourceObjectParams> params_; 85 std::string bundleName_; 86 std::string moduleName_; 87 }; 88 } // namespace Drawable 89 } // namespace Ace 90 } // namespace OHOS 91 92 #endif // FOUNDATION_ACE_INTERFACE_INNERAPI_BASE_RESOURCE_H 93