• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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(EnginePropertyHandle handle, EngineValueOptions) = 0;
47     // Add engine values from value (e.g. member properties or follow EnginePropertyHandle)
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     /// Add single engine value starting from handle and following path
52     virtual bool ConstructValue(EnginePropertyHandle handle, BASE_NS::string_view path, EngineValueOptions) = 0;
53 
54     virtual bool RemoveValue(BASE_NS::string_view name) = 0;
55     virtual void RemoveAll() = 0;
56 
57     virtual IProperty::Ptr ConstructProperty(BASE_NS::string_view name) const = 0;
58     virtual IEngineValue::Ptr GetEngineValue(BASE_NS::string_view name) const = 0;
59     virtual BASE_NS::vector<IProperty::Ptr> ConstructAllProperties() const = 0;
60     virtual BASE_NS::vector<IEngineValue::Ptr> GetAllEngineValues() const = 0;
61 
62     template<typename Type>
ConstructProperty(BASE_NS::string_view name)63     Property<Type> ConstructProperty(BASE_NS::string_view name)
64     {
65         return Property<Type>(ConstructProperty(name));
66     }
67     template<typename Type>
ConstructArrayProperty(BASE_NS::string_view name)68     ArrayProperty<Type> ConstructArrayProperty(BASE_NS::string_view name)
69     {
70         return ArrayProperty<Type>(ConstructProperty(name));
71     }
ConstructValues(EnginePropertyHandle handle)72     bool ConstructValues(EnginePropertyHandle handle)
73     {
74         return ConstructValues(handle, {});
75     }
76 };
77 
78 META_INTERFACE_TYPE(META_NS::IEngineValueManager)
79 META_END_NAMESPACE()
80 
81 #endif
82