1 /* 2 * Copyright (c) 2023-2024 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_FORM_FORM_MODEL_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_FORM_FORM_MODEL_H 18 19 #include <mutex> 20 21 #include "core/components/form/resource/form_request_data.h" 22 #include "core/components_ng/pattern/form/form_event_hub.h" 23 24 namespace OHOS::Ace { 25 class FormModel { 26 public: 27 static FormModel* GetInstance(); 28 virtual ~FormModel() = default; 29 30 virtual void Create(const RequestFormInfo& info) = 0; 31 virtual void SetDimension(int32_t value) = 0; 32 virtual void SetSize(const Dimension& width, const Dimension& height) = 0; 33 virtual void AllowUpdate(bool value) = 0; 34 virtual void SetModuleName(const std::string& value) = 0; 35 virtual void SetOnAcquired(std::function<void(const std::string&)>&& onAcquired) = 0; 36 virtual void SetOnError(std::function<void(const std::string&)>&& onError) = 0; 37 virtual void SetOnUninstall(std::function<void(const std::string&)>&& onUninstall) = 0; 38 virtual void SetOnRouter(std::function<void(const std::string&)>&& onRouter) = 0; 39 virtual void SetOnLoad(std::function<void(const std::string&)>&& onLoad) = 0; 40 virtual void SetVisible(VisibleType visible) = 0; 41 virtual void SetVisibility(VisibleType visible) = 0; 42 virtual void SetObscured(const std::vector<ObscuredReasons>& reasons) = 0; 43 virtual int32_t RequestPublishFormWithSnapshot(const AAFwk::Want& want, 44 const std::string& formBindingDataStr, int64_t& formId, std::string &errMsg) = 0; 45 46 private: 47 static std::unique_ptr<FormModel> instance_; 48 static std::mutex mutex_; 49 }; 50 } // namespace OHOS::Ace 51 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_FORM_FORM_MODEL_H 52