1 /* 2 * Copyright (c) 2021 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_PLUGIN_PLUGIN_COMPONENT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_PLUGIN_PLUGIN_COMPONENT_H 18 19 #include "core/components/box/box_component.h" 20 #include "core/components/plugin/resource/plugin_request_data.h" 21 #include "core/pipeline/base/element.h" 22 23 namespace OHOS::Ace { 24 class ACE_EXPORT PluginComponent : public RenderComponent { 25 DECLARE_ACE_TYPE(PluginComponent, RenderComponent); 26 27 public: 28 PluginComponent() = default; 29 ~PluginComponent() override = default; 30 31 RefPtr<RenderNode> CreateRenderNode() override; 32 RefPtr<Element> CreateElement() override; 33 SetPluginRequestInfo(const RequestPluginInfo & info)34 void SetPluginRequestInfo(const RequestPluginInfo& info) 35 { 36 info_ = info; 37 } 38 GetPluginRequestInfo()39 const RequestPluginInfo& GetPluginRequestInfo() const 40 { 41 return info_; 42 } 43 SetDimension(int32_t dimension)44 void SetDimension(int32_t dimension) 45 { 46 info_.dimension = dimension; 47 } 48 SetModuleName(const std::string & name)49 void SetModuleName(const std::string& name) 50 { 51 info_.moduleName = name; 52 } 53 SetPluginSize(const Dimension & width,const Dimension & height)54 void SetPluginSize(const Dimension& width, const Dimension& height) 55 { 56 info_.width = width; 57 info_.height = height; 58 } 59 GetWidth()60 const Dimension& GetWidth() const 61 { 62 return info_.width; 63 } 64 GetHeight()65 const Dimension& GetHeight() const 66 { 67 return info_.height; 68 } 69 SetOnCompleteEventId(const EventMarker & event)70 void SetOnCompleteEventId(const EventMarker& event) 71 { 72 onComplete_ = event; 73 } 74 GetOnCompleteEventId()75 const EventMarker& GetOnCompleteEventId() const 76 { 77 return onComplete_; 78 } 79 SetOnErrorEventId(const EventMarker & event)80 void SetOnErrorEventId(const EventMarker& event) 81 { 82 onError_ = event; 83 } 84 GetOnErrorEvent()85 const EventMarker& GetOnErrorEvent() const 86 { 87 return onError_; 88 } 89 SetData(const std::string & data)90 void SetData(const std::string& data) 91 { 92 data_ = data; 93 } 94 GetData()95 const std::string& GetData() const 96 { 97 return data_; 98 } 99 100 private: 101 RequestPluginInfo info_; 102 std::string data_; 103 EventMarker onComplete_; 104 EventMarker onError_; 105 }; 106 } // namespace OHOS::Ace 107 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_PLUGIN_PLUGIN_COMPONENT_H