• 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_INTERFACE_PROPERTY_BIND_H
17 #define META_INTERFACE_PROPERTY_BIND_H
18 
19 #include <meta/base/interface_macros.h>
20 #include <meta/base/namespace.h>
21 #include <meta/base/types.h>
22 #include <meta/interface/intf_function.h>
23 #include <meta/interface/property/intf_property.h>
24 
25 META_BEGIN_NAMESPACE()
26 
27 META_REGISTER_INTERFACE(IBind, "29495e67-14a6-40aa-a16f-1923630af506")
28 
29 class IBind : public CORE_NS::IInterface {
30     META_INTERFACE(CORE_NS::IInterface, IBind)
31 public:
32     /**
33      * @brief Set target for the bind object
34      * @param prop/func Target to set (if property, function is created to get the value)
35      * @getDeps if true, tries to find dependencies
36      * @owner Property that uses this bind or nullptr, used to for checking circular dependencies
37      * @return True on success
38      */
39     virtual bool SetTarget(const IProperty::ConstPtr& prop, bool getDeps, const IProperty* owner) = 0;
40     virtual bool SetTarget(const IFunction::ConstPtr& func, bool getDeps, const IProperty* owner) = 0;
41     /// Get the target function for this bind object
42     virtual IFunction::ConstPtr GetTarget() const = 0;
43     /// Explicitly add object this bind depends on (i.e. the value is re-evaluated if the dependency changes)
44     virtual bool AddDependency(const INotifyOnChange::ConstPtr& dep) = 0;
45     /// Remove dependency
46     virtual bool RemoveDependency(const INotifyOnChange::ConstPtr& dep) = 0;
47     /// Get all dependencies
48     virtual BASE_NS::vector<INotifyOnChange::ConstPtr> GetDependencies() const = 0;
49 };
50 
51 META_END_NAMESPACE()
52 
53 #endif
54