• 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 #include "frameworks/core/components_ng/base/view_advanced_register.h"
17 #include "frameworks/core/components_ng/pattern/root/root_pattern.h"
18 
19 namespace OHOS::Ace::NG {
20 thread_local ViewAdvancedRegister* ViewAdvancedRegister::instance_ = nullptr;
21 
GetInstance()22 ViewAdvancedRegister* ViewAdvancedRegister::GetInstance()
23 {
24     if (ViewAdvancedRegister::instance_ == nullptr) {
25         ViewAdvancedRegister::instance_ = new ViewAdvancedRegister();
26     }
27     return ViewAdvancedRegister::instance_;
28 }
29 
CreatePagePattern(const RefPtr<PageInfo> & pageInfo)30 RefPtr<PagePattern> ViewAdvancedRegister::CreatePagePattern(const RefPtr<PageInfo>& pageInfo)
31 {
32     return AceType::MakeRefPtr<PagePattern>(pageInfo);
33 }
34 
GeneratePattern(const std::string & patternName)35 RefPtr<Pattern> ViewAdvancedRegister::GeneratePattern(const std::string& patternName)
36 {
37     if (patternName == V2::STAGE_ETS_TAG) {
38         return AceType::MakeRefPtr<StagePattern>();
39     }
40     if (patternName == V2::ROOT_ETS_TAG) {
41         return AceType::MakeRefPtr<RootPattern>();
42     }
43     return nullptr;
44 }
45 
GenerateStageManager(const RefPtr<FrameNode> & stage)46 RefPtr<StageManager> ViewAdvancedRegister::GenerateStageManager(const RefPtr<FrameNode>& stage)
47 {
48     return AceType::MakeRefPtr<StageManager>(stage);
49 }
50 } // namespace OHOS::Ace::NG