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_OBJECT_H
17 #define SCENE_EXT_IECS_OBJECT_H
18
19 #include <scene/ext/intf_internal_scene.h>
20
21 #include <meta/ext/object.h>
22 #include <meta/interface/engine/intf_engine_value_manager.h>
23
SCENE_BEGIN_NAMESPACE()24 SCENE_BEGIN_NAMESPACE()
25
26 class IEcsResource : public CORE_NS::IInterface {
27 META_INTERFACE(CORE_NS::IInterface, IEcsResource, "4a605fe0-b0bf-4627-8f42-5e7d473e91ba")
28 public:
29 virtual CORE_NS::Entity GetEntity() const = 0;
30 };
31
32 class IEcsObject : public IEcsResource {
33 META_INTERFACE(IEcsResource, IEcsObject, "5576c6f2-364b-497f-b342-4fffeb022e53")
34 public:
35 virtual BASE_NS::string GetPath() const = 0;
36 virtual BASE_NS::string GetName() const = 0;
37 virtual IInternalScene::Ptr GetScene() const = 0;
38 virtual META_NS::IEngineValueManager::Ptr GetEngineValueManager() = 0;
39
40 virtual bool SetName(const BASE_NS::string& name) = 0;
41
42 /**
43 * @brief Add all engine properties that the component defines. Construct new properties if they don't exist yet.
44 * @param object Add properties to this object. Must not be a null pointer.
45 * @param component The name of the component. If empty, add all properties from all components the object has.
46 * @return True if all properties were created, false otherwise.
47 */
48 virtual Future<bool> AddAllProperties(const META_NS::IMetadata::Ptr& object, BASE_NS::string_view component) = 0;
49 virtual Future<bool> AttachProperty(const META_NS::IProperty::Ptr&, BASE_NS::string_view path) = 0;
50 virtual Future<META_NS::IProperty::Ptr> CreateProperty(BASE_NS::string_view path) = 0;
51 virtual Future<META_NS::IProperty::Ptr> CreateProperty(const META_NS::IEngineValue::Ptr&) = 0;
52 virtual Future<bool> AttachProperty(const META_NS::IProperty::Ptr&, const META_NS::IEngineValue::Ptr&) = 0;
53
54 virtual Future<bool> SetActive(bool active) = 0;
55
56 virtual void SyncProperties() = 0;
57 };
58
59 SCENE_END_NAMESPACE()
60
61 META_INTERFACE_TYPE(SCENE_NS::IEcsObject)
62
63 #endif
64