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 RENDER_RENDER__RENDER_NODE_MANAGER_H 17 #define RENDER_RENDER__RENDER_NODE_MANAGER_H 18 19 #include <base/containers/string.h> 20 #include <base/containers/unique_ptr.h> 21 #include <base/containers/unordered_map.h> 22 #include <core/namespace.h> 23 #include <render/intf_plugin.h> 24 #include <render/namespace.h> 25 26 CORE_BEGIN_NAMESPACE() 27 class IInterfaceRegister; 28 CORE_END_NAMESPACE() 29 RENDER_BEGIN_NAMESPACE() 30 class IRenderNode; 31 32 /** 33 */ 34 class RenderNodeManager final { 35 public: 36 RenderNodeManager() = default; 37 ~RenderNodeManager() = default; 38 39 RenderNodeManager(const RenderNodeManager&) = delete; 40 RenderNodeManager& operator=(const RenderNodeManager&) = delete; 41 42 IRenderNode* Create(char const* nodeType); 43 void Destroy(char const* nodeType, IRenderNode* aInstance); 44 45 BASE_NS::unique_ptr<IRenderNode, RENDER_NS::RenderNodeTypeInfo::DestroyRenderNodeFn> CreateRenderNode( 46 char const* nodeType); 47 48 struct RenderNodeTypeInfoFlags { 49 RENDER_NS::RenderNodeTypeInfo::PluginRenderNodeBackendFlags backendFlags { 0 }; 50 RENDER_NS::RenderNodeTypeInfo::PluginRenderNodeClassType classType { 0 }; 51 }; 52 RenderNodeTypeInfoFlags GetRenderNodeTypeInfoFlags(char const* nodeType); 53 54 void AddRenderNodeFactory(const RenderNodeTypeInfo& typeInfo); 55 void RemoveRenderNodeFactory(const RenderNodeTypeInfo& typeInfo); 56 57 private: 58 BASE_NS::unordered_map<BASE_NS::string, RENDER_NS::RenderNodeTypeInfo> factories_; 59 }; 60 RENDER_END_NAMESPACE() 61 62 #endif // CORE__RENDER__RENDER_NODE_MANAGER_H 63