1 /*
2  * Copyright (c) 2023 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_COMMON_RESOURCE_RESOURCE_OBJECT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_RESOURCE_RESOURCE_OBJECT_H
18 
19 #include <cstdint>
20 #include <optional>
21 #include <string>
22 #include <vector>
23 
24 #include "base/memory/ace_type.h"
25 
26 namespace OHOS::Ace {
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 ResourceObject : public AceType {
35     DECLARE_ACE_TYPE(ResourceObject, AceType);
36 
37 public:
ResourceObject(int32_t id,int32_t type,const std::vector<ResourceObjectParams> & params,const std::string & bundleName,const std::string & moduleName)38     ResourceObject(int32_t id, int32_t type, const std::vector<ResourceObjectParams>& params,
39         const std::string& bundleName, const std::string& moduleName)
40         : id_(id), type_(type), params_(params), bundleName_(bundleName), moduleName_(moduleName) {};
ResourceObject(const std::string & bundleName,const std::string & moduleName)41     ResourceObject(const std::string& bundleName, const std::string& moduleName)
42         : id_(-1), type_(-1), params_(std::vector<ResourceObjectParams>()), bundleName_(bundleName),
43           moduleName_(moduleName) {};
44     ~ResourceObject() = default;
45 
GetId()46     int32_t GetId() const
47     {
48         return id_;
49     }
50 
GetType()51     int32_t GetType() const
52     {
53         return type_;
54     }
55 
GetParams()56     std::vector<ResourceObjectParams> GetParams() const
57     {
58         return params_;
59     }
60 
GetBundleName()61     std::string GetBundleName() const
62     {
63         return bundleName_;
64     }
65 
GetModuleName()66     std::string GetModuleName() const
67     {
68         return moduleName_;
69     }
70 
71 private:
72     int32_t id_;
73     int32_t type_;
74     std::vector<ResourceObjectParams> params_;
75     std::string bundleName_;
76     std::string moduleName_;
77 };
78 } // namespace OHOS::Ace
79 
80 #endif