1/*
2 * Copyright (c) 2023 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 FOUNDATION_ACE_NAPI_MODULE_MANAGER_MODULE_CHECKER_H
16#define FOUNDATION_ACE_NAPI_MODULE_MANAGER_MODULE_CHECKER_H
17
18#include <memory>
19#include <functional>
20
21typedef std::function<bool(const std::string&)> ApiAllowListChecker;
22
23/**
24 * @brief Module checker interface. check whether module can be loaded
25 *
26 */
27class ModuleCheckerDelegate {
28public:
29    virtual ~ModuleCheckerDelegate() = default;
30
31    /**
32     * @brief Check whether the module is allowed to be loaded
33     *
34     * @param moduleName module name
35     * @return true The module can be loaded
36     * @return false The module cannot be loaded
37     */
38    virtual bool CheckModuleLoadable(const char* moduleName,
39        std::unique_ptr<ApiAllowListChecker>& apiAllowListChecker) = 0;
40
41    /**
42     * @brief Whether loadable rules only work for disk case
43     *
44     * @return true Disk check only
45     * @return false Check both cache and disk
46     */
47    virtual bool DiskCheckOnly();
48};
49
50#endif /* FOUNDATION_ACE_NAPI_MODULE_MANAGER_MODULE_CHECKER_H */
51