1 /* 2 * Copyright (c) 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_NG_PATTERNS_STAGE_PAGE_INFO_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_STAGE_PAGE_INFO_H 18 19 #include <cstdint> 20 #include <string> 21 #include <utility> 22 23 #include "base/memory/ace_type.h" 24 #include "base/utils/noncopyable.h" 25 #include "core/components/dialog/dialog_properties.h" 26 27 namespace OHOS::Ace::NG { 28 29 class ACE_EXPORT PageInfo : public AceType { 30 DECLARE_ACE_TYPE(PageInfo, AceType); 31 32 public: 33 PageInfo() = default; 34 ~PageInfo() override = default; PageInfo(int32_t pageId,std::string url,std::string path)35 PageInfo(int32_t pageId, std::string url, std::string path) 36 : pageId_(pageId), url_(std::move(url)), path_(std::move(path)) 37 {} GetPageId()38 int32_t GetPageId() const 39 { 40 return pageId_; 41 } 42 GetPageUrl()43 const std::string& GetPageUrl() const 44 { 45 return url_; 46 } 47 GetPagePath()48 const std::string& GetPagePath() const 49 { 50 return path_; 51 } 52 GetAlertCallback()53 const std::function<void(int32_t)>& GetAlertCallback() const 54 { 55 return alertCallback_; 56 } 57 GetDialogProperties()58 const DialogProperties& GetDialogProperties() const 59 { 60 return dialogProperties_; 61 } 62 SetAlertCallback(std::function<void (int32_t)> && callback)63 void SetAlertCallback(std::function<void(int32_t)>&& callback) 64 { 65 alertCallback_ = callback; 66 } 67 SetDialogProperties(const DialogProperties & dialogProperties)68 void SetDialogProperties(const DialogProperties& dialogProperties) 69 { 70 dialogProperties_ = dialogProperties; 71 } 72 SetPageIndex(int32_t pageIndex)73 void SetPageIndex(int32_t pageIndex) 74 { 75 pageIndex_ = pageIndex; 76 } 77 GetPageIndex()78 int32_t GetPageIndex() const 79 { 80 return pageIndex_; 81 } 82 SetFullPath(const std::string & fullPath)83 void SetFullPath(const std::string& fullPath) 84 { 85 fullPath_ = fullPath; 86 } 87 GetFullPath()88 const std::string& GetFullPath() const 89 { 90 return fullPath_; 91 } 92 GetRouteName()93 std::optional<std::string> GetRouteName() const 94 { 95 return routeName_; 96 } 97 SetRouteName(const std::optional<std::string> & name)98 void SetRouteName(const std::optional<std::string>& name) 99 { 100 routeName_ = name; 101 } 102 103 private: 104 int32_t pageId_ = 0; 105 int32_t pageIndex_ = -1; 106 std::string url_; 107 std::string path_; 108 std::string fullPath_; 109 110 std::optional<std::string> routeName_; 111 112 std::function<void(int32_t)> alertCallback_; 113 DialogProperties dialogProperties_; 114 115 ACE_DISALLOW_COPY_AND_MOVE(PageInfo); 116 }; 117 } // namespace OHOS::Ace::NG 118 119 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_STAGE_PAGE_INFO_H 120