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 #ifndef INTF_NODE_PRIVATE_H 16 #define INTF_NODE_PRIVATE_H 17 18 #include <scene_plugin/interface/intf_ecs_object.h> 19 #include <scene_plugin/interface/intf_material.h> 20 #include <scene_plugin/interface/intf_scene.h> 21 22 #include "scene_holder.h" 23 24 enum NodeLifeCycle : uint32_t { 25 NODE_LC_UNKNOWN = 0, 26 NODE_LC_MIRROR_EXISTING = 1 << 1, 27 NODE_LC_CLONED = 1 << 2, 28 NODE_LC_CREATED = 1 << 3, 29 }; 30 31 REGISTER_INTERFACE(INodeEcsInterfacePrivate, "f78b73b2-1f9e-45d8-9938-93525604ada0") 32 class INodeEcsInterfacePrivate : public CORE_NS::IInterface { 33 META_INTERFACE(CORE_NS::IInterface, INodeEcsInterfacePrivate, InterfaceId::INodeEcsInterfacePrivate) 34 public: 35 virtual bool Initialize(SCENE_NS::IEcsScene::Ptr& scene, SCENE_NS::IEcsObject::Ptr& ecsObject, 36 SCENE_NS::INode::Ptr parent, const BASE_NS::string& path, const BASE_NS::string& name, 37 SceneHolder::WeakPtr sceneHolder, CORE_NS::Entity entity) = 0; 38 virtual bool CompleteInitialization(const BASE_NS::string& path) = 0; 39 40 virtual SCENE_NS::IEcsScene::Ptr EcsScene() const = 0; 41 virtual SCENE_NS::IEcsObject::Ptr EcsObject() const = 0; 42 virtual SceneHolder::Ptr SceneHolder() const = 0; 43 44 virtual void SetPath(const BASE_NS::string& path, const BASE_NS::string& name, CORE_NS::Entity entity) = 0; 45 46 virtual void ClaimOwnershipOfEntity(bool ownsEntity) = 0; 47 48 // Node is potentially moving to a new position within a parent 49 virtual void SetIndex(size_t index) = 0; 50 51 // Node was removed from container, we don't currently reflect this as such to ecs 52 // We may have to change that someday (even soon) 53 virtual void RemoveIndex(size_t index) = 0; 54 55 virtual META_NS::IProperty::Ptr GetLifecycleInfo(bool create = true) = 0; 56 57 virtual bool ShouldExport() const = 0; 58 }; 59 60 REGISTER_INTERFACE(ITextureStorage, "259a9809-d458-4eb4-a5c5-6b0134780d2d") 61 class ITextureStorage : public CORE_NS::IInterface { 62 META_INTERFACE(CORE_NS::IInterface, ITextureStorage, InterfaceId::ITextureStorage) 63 public: 64 virtual SCENE_NS::ITextureInfo::Ptr GetTextureInfo(size_t ix) const = 0; 65 }; 66 67 REGISTER_INTERFACE(IMaterialInputBindable, "a3438f52-6edf-4e9e-b86a-68cc92d01ae5") 68 class IMaterialInputBindable : public CORE_NS::IInterface { 69 META_INTERFACE(CORE_NS::IInterface, IMaterialInputBindable, InterfaceId::IMaterialInputBindable) 70 public: 71 virtual void Bind(const ITextureStorage::Ptr& infos) = 0; 72 }; 73 74 REGISTER_INTERFACE(ISceneHolderRef, "57dd6eab-aeb8-40b0-b606-512787c8773b") 75 class ISceneHolderRef : public CORE_NS::IInterface { 76 META_INTERFACE(CORE_NS::IInterface, ISceneHolderRef, InterfaceId::IMaterialInputBindable) 77 public: 78 virtual void SetSceneHolder(const SceneHolder::WeakPtr& sh) = 0; 79 virtual SceneHolder::Ptr SceneHolder() = 0; 80 // ToDo: This should be part of some other interface SetIndex(size_t ix)81 virtual void SetIndex(size_t ix) {} 82 }; 83 84 SCENE_BEGIN_NAMESPACE() 85 REGISTER_INTERFACE(IPendingRequestData, "197c37b3-dd55-45af-9b14-aada2b224046") 86 template<typename T> 87 class IPendingRequestData : public CORE_NS::IInterface { 88 META_INTERFACE(CORE_NS::IInterface, IPendingRequestData, InterfaceId::IPendingRequestData) 89 public: 90 virtual void Add(const T& data) = 0; 91 virtual void MarkReady() = 0; 92 virtual BASE_NS::vector<BASE_NS::string>& MetaData() = 0; 93 virtual BASE_NS::vector<T>& MutableData() = 0; 94 }; 95 96 REGISTER_CLASS(PendingDistanceRequest, "d645fcd5-871c-4780-89a9-899df02b7121", META_NS::ObjectCategoryBits::NO_CATEGORY) 97 REGISTER_CLASS( 98 PendingGraphicsStateRequest, "2d21475b-19be-4110-938a-f37724f518c4", META_NS::ObjectCategoryBits::NO_CATEGORY) 99 REGISTER_CLASS(PendingVec3Request, "36eb3eb2-f81d-4db5-8ab7-3c76e8674ecf", META_NS::ObjectCategoryBits::NO_CATEGORY) 100 SCENE_END_NAMESPACE() 101 102 #endif 103