1 /*
2  * Copyright (c) 2020 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 #ifndef OHOS_ACELITE_PRESET_MODULE_H
16 #define OHOS_ACELITE_PRESET_MODULE_H
17 
18 #include "js_fwk_common.h"
19 #include "non_copyable.h"
20 
21 namespace OHOS {
22 namespace ACELite {
23 class PresetModule : public MemoryHeap {
24 public:
25     ACE_DISALLOW_COPY_AND_MOVE(PresetModule);
26     /**
27      * @fn PresetModule::PresetModule()
28      *
29      * @brief Constructor.
30      */
31     PresetModule() = delete;
32 
33     /**
34      * @fn PresetModule::PresetModule(const char* name)
35      *
36      * @brief Constructor.
37      */
38     explicit PresetModule(const char * const name);
39 
40     /**
41      * @fn PresetModule::~PresetModule()
42      *
43      * @brief Destructor.
44      */
45     ~PresetModule();
46 
47     /**
48      * @fn PresetModule::Init
49      *
50      * @brief Initialize module
51      */
52     virtual void Init() = 0;
53 
54 protected:
55     /**
56      * @fn PresetModule::CreateNamedFunction(char* funcName, jerry_external_handler_t handler)
57      *
58      * @brief create a new named function
59      * @param funcName the name of new function
60      * @param handler the handler of new function
61      */
62     void CreateNamedFunction(const char * const funcName, jerry_external_handler_t handler);
63 
64 private:
65     jerry_value_t module_;
66     char* moduleName_;
67 };
68 } // namespace ACELite
69 } // namespace OHOS
70 
71 #endif // OHOS_ACELITE_PRESET_MODULE_H
72