1 /*
2  * Copyright (c) 2020-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 OHOS_ACELITE_COMPONENT_UTILS_H
17 #define OHOS_ACELITE_COMPONENT_UTILS_H
18 
19 #include "js_fwk_common.h"
20 #include "non_copyable.h"
21 #include "ui_view.h"
22 
23 namespace OHOS {
24 namespace ACELite {
25 class Component;
26 
27 class ComponentUtils final : public MemoryHeap {
28 public:
29     ACE_DISALLOW_COPY_AND_MOVE(ComponentUtils);
~ComponentUtils()30     ~ComponentUtils() {}
31     /**
32      * @brief Easy method to get the root UIView from the component binded to the given JS object.
33      */
34     static UIView* GetViewFromBindingObject(jerry_value_t value);
35     /**
36      * @brief Easy method to get the the component binded to the given JS object.
37      */
38     static Component* GetComponentFromBindingObject(jerry_value_t value);
39     static void ReleaseComponents(Component *rootComponent);
40     /**
41      * @brief Easy method to get the the component type.
42      */
43     static uint16_t GetComponentType(jerry_value_t options);
44 };
45 } // namespace ACELite
46 } // namespace OHOS
47 #endif // OHOS_ACELITE_COMPONENT_UTILS_H
48