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 SCENE_EXT_IECS_CONTEXT_H 17 #define SCENE_EXT_IECS_CONTEXT_H 18 19 #include <scene/base/namespace.h> 20 #include <scene/ext/intf_ecs_object.h> 21 22 #include <core/ecs/intf_component_manager.h> 23 #include <core/ecs/intf_ecs.h> 24 25 #include <meta/ext/object.h> 26 SCENE_BEGIN_NAMESPACE()27SCENE_BEGIN_NAMESPACE() 28 29 class IEcsContext : public CORE_NS::IInterface { 30 META_INTERFACE(CORE_NS::IInterface, IEcsContext, "5576c6f2-364b-497f-b342-4fffeb022e53") 31 public: 32 virtual bool CreateUnnamedRootNode() = 0; 33 virtual CORE_NS::IEcs::Ptr GetNativeEcs() const = 0; 34 virtual CORE_NS::IComponentManager* FindComponent(BASE_NS::string_view name) const = 0; 35 36 template<typename ComponentType> 37 CORE_NS::IComponentManager* FindComponent() const 38 { 39 return FindComponent(CORE_NS::GetName<ComponentType>()); 40 } 41 42 virtual void AddDefaultComponents(CORE_NS::Entity ent) const = 0; 43 virtual BASE_NS::string GetPath(CORE_NS::Entity ent) const = 0; 44 virtual IEcsObject::Ptr GetEcsObject(CORE_NS::Entity) = 0; 45 virtual void RemoveEcsObject(const IEcsObject::ConstPtr&) = 0; 46 virtual CORE_NS::Entity GetRootEntity() const = 0; 47 virtual CORE_NS::Entity GetParent(CORE_NS::Entity ent) const = 0; 48 virtual CORE_NS::EntityReference GetRenderHandleEntity(const RENDER_NS::RenderHandleReference& handle) = 0; 49 50 virtual bool IsNodeEntity(CORE_NS::Entity ent) const = 0; 51 virtual bool RemoveEntity(CORE_NS::Entity ent) = 0; 52 }; 53 54 SCENE_END_NAMESPACE() 55 56 META_INTERFACE_TYPE(SCENE_NS::IEcsContext) 57 58 #endif 59