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 
SetWidth(const Dimension & width)65     void SetWidth(const Dimension& width)
66     {
67         info_.width = width;
68     }
69 
GetHeight()70     const Dimension& GetHeight() const
71     {
72         return info_.height;
73     }
74 
SetHeight(const Dimension & height)75     void SetHeight(const Dimension& height)
76     {
77         info_.height = height;
78     }
79 
SetOnCompleteEventId(const EventMarker & event)80     void SetOnCompleteEventId(const EventMarker& event)
81     {
82         onComplete_ = event;
83     }
84 
GetOnCompleteEventId()85     const EventMarker& GetOnCompleteEventId() const
86     {
87         return onComplete_;
88     }
89 
SetOnErrorEventId(const EventMarker & event)90     void SetOnErrorEventId(const EventMarker& event)
91     {
92         onError_ = event;
93     }
94 
GetOnErrorEvent()95     const EventMarker& GetOnErrorEvent() const
96     {
97         return onError_;
98     }
99 
SetData(const std::string & data)100     void SetData(const std::string& data)
101     {
102         data_ = data;
103     }
104 
GetData()105     const std::string& GetData() const
106     {
107         return data_;
108     }
109 
110 private:
111     RequestPluginInfo info_;
112     std::string data_;
113     EventMarker onComplete_;
114     EventMarker onError_;
115 };
116 } // namespace OHOS::Ace
117 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_PLUGIN_PLUGIN_COMPONENT_H
118