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_IPROXY_OBJECT_H 17 #define META_INTERFACE_IPROXY_OBJECT_H 18 19 #include <meta/base/bit_field.h> 20 #include <meta/interface/interface_macros.h> 21 #include <meta/interface/intf_object.h> 22 23 META_BEGIN_NAMESPACE() 24 25 META_REGISTER_INTERFACE(IProxyObject, "0bb4f08c-bdec-408e-b6f0-0fb19c2d2bf6") 26 27 enum class ProxyMode : uint8_t { REFLECT_PROXY_HIERARCHY = 1 }; 28 29 using ProxyModeBitsValue = EnumBitField<ProxyMode>; 30 31 /** 32 * @brief The IProxyObject interface defines an interface for a proxy object which 33 * exposes all of the properties and functions of its target object as its own 34 * properties/functions by default. 35 * Any changes to the property values are reflected in the target object as 36 * long as a property is not overriden. 37 */ 38 class IProxyObject : public CORE_NS::IInterface { 39 META_INTERFACE(CORE_NS::IInterface, IProxyObject) 40 public: 41 META_PROPERTY(ProxyModeBitsValue, Mode) 42 /** 43 * @brief If true, the proxy object will dynamically reflect any metadata changes 44 * in the target object. If false, the target object's metadata is reflected 45 * in the proxy object only at the time of setting the target. 46 * The default value is true. 47 */ 48 META_PROPERTY(bool, Dynamic) 49 /** 50 * @brief Returns the current target object. 51 */ 52 virtual const IObject::Ptr GetTarget() const = 0; 53 /** 54 * @brief Sets the target object for this proxy. 55 * @param target The target object for proxying. 56 */ 57 virtual bool SetTarget(const IObject::Ptr& target) = 0; 58 /** 59 * @brief Returns a list of properties which have been locally overridden 60 * in the proxy object. 61 */ 62 virtual BASE_NS::vector<IProperty::ConstPtr> GetOverrides() const = 0; 63 /** 64 * @brief Returns property if it has been locally overridden in the proxy object 65 **/ 66 virtual IProperty::ConstPtr GetOverride(BASE_NS::string_view) const = 0; 67 /** 68 * @brief Sets target property to proxy for individual property. Returns the proxying property. 69 */ 70 virtual IProperty::Ptr SetPropertyTarget(const IProperty::Ptr& property) = 0; 71 /** 72 * @brief returns the property if it is a proxy 73 */ 74 virtual IProperty::ConstPtr GetProxyProperty(BASE_NS::string_view) const = 0; 75 }; 76 77 META_END_NAMESPACE() 78 79 META_TYPE(META_NS::IProxyObject::Ptr); 80 META_TYPE(META_NS::IProxyObject::WeakPtr); 81 META_TYPE(META_NS::ProxyModeBitsValue) 82 83 #endif 84