1 /*
2  * Copyright (c) 2024 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 ACE_FRAMEWORKDELEGATE_H
17 #define ACE_FRAMEWORKDELEGATE_H
18 
19 #include "bridge/cj_frontend/interfaces/cj_ffi/cj_common_ffi.h"
20 
21 namespace OHOS::Ace::Framework {
22 
23 class ACE_EXPORT CJRuntimeDelegate {
24 public:
GetInstance()25     static CJRuntimeDelegate* GetInstance()
26     {
27         if (instance_ == nullptr) {
28             instance_ = new CJRuntimeDelegate();
29         }
30         return instance_;
31     }
32 
33 private:
34     static CJRuntimeDelegate* instance_;
35 
36 public:
37     ACE_DISALLOW_COPY_AND_MOVE(CJRuntimeDelegate);
38 
39 private:
40     CJRuntimeDelegate() = default;
41 
42 public:
43     void RegisterCJFuncs(AtCPackage funcs);
GetCJFuncs()44     const AtCPackage& GetCJFuncs() const
45     {
46         return atCPackage_;
47     }
48 
49     bool LoadAppEntry(const std::string& name);
50 
51     void* LoadCJLibrary(const char* dlName);
52     void* GetUIScheduler();
53 
54 private:
55     bool LoadAtCPackage();
56 
57     AtCPackage atCPackage_;
58     bool atCPackageLoaded_ = false;
59 };
60 
61 } // namespace OHOS::Ace::Framework
62 
63 #endif // ACE_FRAMEWORKDELEGATE_H
64