• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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);
44     void RegisterCJFuncsV2(void (*callback)(AtCPackageV2* cjFuncs));
45     void RegisterCJXCompCtrFuncs(AtCXComponentCallback funcs);
GetCJFuncs()46     const AtCPackage& GetCJFuncs() const
47     {
48         return atCPackage_;
49     }
50 
GetCJFuncsV2()51     const AtCPackageV2& GetCJFuncsV2() const
52     {
53         return atCPackageV2_;
54     }
55 
GetCJXcompCtrFuncs()56     const AtCXComponentCallback& GetCJXcompCtrFuncs() const
57     {
58         return atCXcompCtr_;
59     }
60 
61     bool LoadAppEntry(const std::string& name);
62     bool CheckLoadCJLibrary();
63 
64     void* LoadCJLibrary(const char* dlName);
65     void* GetUIScheduler();
66 
67 private:
68     bool LoadAtCPackage();
69 
70     AtCPackage atCPackage_;
71     bool atCPackageLoaded_ = false;
72 
73     AtCPackageV2 atCPackageV2_;
74     bool atCPackageLoadedV2_ = false;
75 
76     AtCXComponentCallback atCXcompCtr_;
77     bool atCXcompCtrLoaded_ = false;
78 };
79 
80 } // namespace OHOS::Ace::Framework
81 
82 #endif // ACE_FRAMEWORKDELEGATE_H
83