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 SCENEPLUGIN_INTF_ECSOBJECT_H 17 #define SCENEPLUGIN_INTF_ECSOBJECT_H 18 19 #include <scene_plugin/interface/intf_entity_collection.h> 20 #include <scene_plugin/namespace.h> 21 22 #include <base/containers/vector.h> 23 #include <base/containers/unordered_map.h> 24 #include <core/ecs/entity.h> 25 #include <core/ecs/intf_ecs.h> 26 #include <core/plugin/intf_interface.h> 27 28 #include <meta/base/types.h> 29 #include <meta/interface/intf_object.h> 30 #include <meta/interface/interface_macros.h> 31 #include <meta/interface/property/property.h> 32 33 SCENE_BEGIN_NAMESPACE() 34 35 REGISTER_INTERFACE(IEcsValueInformation, "20c0b2da-59d1-4f63-93be-a5015f3c88f1") 36 class IEcsValueInformation : public CORE_NS::IInterface { 37 META_INTERFACE(CORE_NS::IInterface, IEcsValueInformation, InterfaceId::IEcsValueInformation) 38 public: 39 virtual BASE_NS::string_view GetPath() const = 0; 40 virtual CORE_NS::Entity GetEntity() const = 0; 41 virtual CORE_NS::IEcs::Ptr GetEcs() const = 0; 42 virtual BASE_NS::Uid GetComponentUid() const = 0; 43 }; 44 45 SCENE_END_NAMESPACE() 46 47 META_TYPE(SCENE_NS::IEcsValueInformation::Ptr); 48 META_TYPE(SCENE_NS::IEcsValueInformation::WeakPtr); 49 50 SCENE_BEGIN_NAMESPACE() 51 52 REGISTER_INTERFACE(IEcsObject, "f3eb2abf-56c5-49a2-bcf7-c1e8807bb764") 53 REGISTER_CLASS(EcsObject, "067c9c4f-ecde-417b-b3be-d4e48dfe4d14", META_NS::ObjectCategoryBits::NO_CATEGORY) 54 55 class IEcsObject : public CORE_NS::IInterface { 56 META_INTERFACE(CORE_NS::IInterface, IEcsObject, InterfaceId::IEcsObject) 57 public: 58 enum EcsObjectStatus { 59 /** Instance exists, but the properties are not bound*/ 60 ECS_OBJ_STATUS_DISCONNECTED = 0, 61 /** The node is bound to 3D scene*/ 62 ECS_OBJ_STATUS_CONNECTED = 1, 63 }; 64 META_READONLY_PROPERTY(uint8_t, ConnectionStatus) 65 66 virtual CORE_NS::IEcs::Ptr GetEcs() const = 0; 67 virtual void SetEntity(CORE_NS::IEcs::Ptr ecs, CORE_NS::Entity entity) = 0; 68 virtual CORE_NS::Entity GetEntity() const = 0; 69 virtual void BindObject(CORE_NS::IEcs::Ptr ecsInstance, CORE_NS::Entity entity) = 0; 70 71 // Update property mappings according the targets. Refresh component bindings 72 virtual void DefineTargetProperties( 73 BASE_NS::unordered_map<BASE_NS::string_view, BASE_NS::vector<BASE_NS::string_view>> names) = 0; 74 75 // Maintain a list of entities that refer to this entity, e.g. animation host 76 virtual BASE_NS::vector<CORE_NS::Entity> GetAttachments() = 0; 77 virtual void AddAttachment(CORE_NS::Entity entity) = 0; 78 virtual void RemoveAttachment(CORE_NS::Entity entity) = 0; 79 80 virtual void Activate() = 0; 81 virtual void Deactivate() = 0; 82 }; 83 84 SCENE_END_NAMESPACE() 85 86 META_TYPE(SCENE_NS::IEcsObject::Ptr); 87 META_TYPE(SCENE_NS::IEcsObject::WeakPtr); 88 89 #endif // SCENEPLUGIN_INTF_ECSOBJECT_H 90