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 META_ENGINE_INTERFACE_ENGINE_VALUE_MANAGER_H 17 #define META_ENGINE_INTERFACE_ENGINE_VALUE_MANAGER_H 18 19 #include <meta/interface/engine/intf_engine_value.h> 20 #include <meta/interface/intf_task_queue.h> 21 #include <meta/interface/property/array_property.h> 22 #include <meta/interface/property/property.h> 23 24 META_BEGIN_NAMESPACE() 25 26 META_REGISTER_INTERFACE(IEngineValueManager, "542b7e13-21bd-4c9c-8d3f-a9527732216c") 27 28 struct EngineValueOptions { 29 /// prefix that is added before the name (plus '.') 30 BASE_NS::string namePrefix; 31 /// optional output vector to put all constructed values 32 BASE_NS::vector<IEngineValue::Ptr>* values {}; 33 /// Push value directly to engine when set, if this is enabled, the values can only be set in the engine task queue 34 /// thread 35 bool pushValuesDirectlyToEngine {}; 36 }; 37 38 class IEngineValueManager : public CORE_NS::IInterface { 39 META_INTERFACE(CORE_NS::IInterface, IEngineValueManager) 40 public: 41 virtual void SetNotificationQueue(const ITaskQueue::WeakPtr&) = 0; 42 43 virtual bool Sync(EngineSyncDirection) = 0; 44 45 /// Add engine values from the handle 46 virtual bool ConstructValues(CORE_NS::IPropertyHandle* handle, EngineValueOptions) = 0; 47 // Add engine values from value (e.g. member properties or follow IPropertyHandle*) 48 virtual bool ConstructValues(IValue::Ptr value, EngineValueOptions) = 0; 49 // Add single engine value from EnginePropertyParams 50 virtual bool ConstructValue(EnginePropertyParams property, EngineValueOptions) = 0; 51 virtual bool ConstructValue(CORE_NS::IPropertyHandle* handle, BASE_NS::string_view path, EngineValueOptions) = 0; 52 53 virtual bool RemoveValue(BASE_NS::string_view name) = 0; 54 virtual void RemoveAll() = 0; 55 56 virtual IProperty::Ptr ConstructProperty(BASE_NS::string_view name) const = 0; 57 virtual IEngineValue::Ptr GetEngineValue(BASE_NS::string_view name) const = 0; 58 virtual BASE_NS::vector<IProperty::Ptr> ConstructAllProperties() const = 0; 59 virtual BASE_NS::vector<IEngineValue::Ptr> GetAllEngineValues() const = 0; 60 61 template<typename Type> ConstructProperty(BASE_NS::string_view name)62 Property<Type> ConstructProperty(BASE_NS::string_view name) 63 { 64 return Property<Type>(ConstructProperty(name)); 65 } 66 template<typename Type> ConstructArrayProperty(BASE_NS::string_view name)67 ArrayProperty<Type> ConstructArrayProperty(BASE_NS::string_view name) 68 { 69 return ArrayProperty<Type>(ConstructProperty(name)); 70 } ConstructValues(CORE_NS::IPropertyHandle * handle)71 bool ConstructValues(CORE_NS::IPropertyHandle* handle) 72 { 73 return ConstructValues(handle, {}); 74 } 75 }; 76 77 META_INTERFACE_TYPE(IEngineValueManager); 78 META_END_NAMESPACE() 79 80 #endif 81