• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 USCRIPT_INSTRUCTION_HELPER_H
17 #define USCRIPT_INSTRUCTION_HELPER_H
18 
19 #include "script_instruction.h"
20 #include "script_manager_impl.h"
21 #include "script_utils.h"
22 
23 namespace uscript {
24 class ScriptInstructionHelper {
25 public:
ScriptInstructionHelper(ScriptManagerImpl * impl)26     explicit ScriptInstructionHelper(ScriptManagerImpl *impl) : scriptManager_(impl) {}
27 
28     ~ScriptInstructionHelper();
29 
30     int32_t RegisterInstructions() const;
31 
32     bool IsReservedInstruction(const std::string &scriptName) const;
33 
34     int32_t AddScript(const std::string &scriptName, int32_t priority);
35 
36     int32_t AddInstruction(const std::string &instrName, const UScriptInstructionPtr instr);
37 
38     int32_t RegisterUserInstruction(const std::string &libName, const std::string &instrName);
39 
40     static ScriptInstructionHelper* GetBasicInstructionHelper(ScriptManagerImpl *impl = nullptr);
41 
42     static void ReleaseBasicInstructionHelper();
43 private:
44     void* instrLib_ = nullptr;
45     std::string userInstrLibName_ {};
46     ScriptManagerImpl* scriptManager_ {};
47 };
48 } // namespace uscript
49 #endif // USCRIPT_INSTRUCTION_HELPER_H
50