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_FORM_RESOURCE_FORM_REQUEST_DATA_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_FORM_RESOURCE_FORM_REQUEST_DATA_H
18 
19 #include <sstream>
20 #include <string>
21 
22 #include "base/geometry/dimension.h"
23 #include "base/utils/utils.h"
24 #include "base/want/want_wrap.h"
25 
26 namespace OHOS::Ace {
27 
28 struct RequestFormInfo {
29     int64_t id = 0;
30     std::string cardName;
31     std::string bundleName;
32     std::string abilityName;
33     std::string moduleName;
34     RefPtr<WantWrap> wantWrap;
35     bool temporary = false;
36     int32_t dimension = -1;
37     bool allowUpdate = true;
38     Dimension width;
39     Dimension height;
40     int32_t renderingMode = 0;
41     uint64_t index = GetNanoseconds();
42     float borderWidth = 0.0f;
43     bool obscuredMode = false;
44     int32_t shape = -1;
45 
ToStringRequestFormInfo46     std::string ToString() const
47     {
48         std::stringstream paramStream;
49         paramStream << bundleName << abilityName << moduleName << cardName << dimension << renderingMode
50             << index << temporary << shape;
51         if (wantWrap) {
52             paramStream << wantWrap->ToString();
53         }
54         return paramStream.str();
55     }
56 
57     bool operator==(const RequestFormInfo& formInfo) const
58     {
59         return id == formInfo.id && cardName == formInfo.cardName && bundleName == formInfo.bundleName &&
60                abilityName == formInfo.abilityName && moduleName == formInfo.moduleName &&
61                temporary == formInfo.temporary && dimension == formInfo.dimension &&
62                allowUpdate == formInfo.allowUpdate && width == formInfo.width && height == formInfo.height &&
63                renderingMode == formInfo.renderingMode && index == formInfo.index && wantWrap == formInfo.wantWrap &&
64                shape == formInfo.shape;
65     }
66 };
67 
68 } // namespace OHOS::Ace
69 
70 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_FORM_RESOURCE_FORM_REQUEST_DATA_H