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_SRC_OBJECT_CONTEXT_H
17 #define META_SRC_OBJECT_CONTEXT_H
18
19 #include <meta/base/namespace.h>
20 #include <meta/ext/object.h>
21 #include <meta/interface/builtin_objects.h>
22 #include <meta/interface/intf_object_context.h>
23 #include <meta/interface/intf_proxy_object.h>
24
25 #include "object.h"
26
META_BEGIN_NAMESPACE()27 META_BEGIN_NAMESPACE()
28
29 namespace Internal {
30
31 class ObjectContext final : public META_NS::ObjectFwd<ObjectContext, META_NS::ClassId::ObjectContext,
32 META_NS::ClassId::ProxyObject, IProxyObject, IObjectContext> {
33 public:
34 ObjectContext() = default;
35 ~ObjectContext() override = default;
36
37 public: // ILifecycle
38 void SetSuperInstance(const META_NS::IObject::Ptr& aggr, const META_NS::IObject::Ptr& super) override;
39
40 public: // IProxyObject
41 META_FORWARD_PROPERTY(ProxyModeBitsValue, Mode, proxy_->Mode())
42 META_FORWARD_PROPERTY(bool, Dynamic, proxy_->Dynamic())
43 const IObject::Ptr GetTarget() const override;
44 bool SetTarget(const IObject::Ptr& target) override;
45 BASE_NS::vector<IProperty::ConstPtr> GetOverrides() const override;
46 IProperty::ConstPtr GetOverride(BASE_NS::string_view name) const override;
47 IProperty::Ptr SetPropertyTarget(const IProperty::Ptr& property) override;
48 IProperty::ConstPtr GetProxyProperty(BASE_NS::string_view name) const override;
49
50 public: // IMetadata
51 IProperty::Ptr GetPropertyByName(BASE_NS::string_view name) override;
52 IProperty::ConstPtr GetPropertyByName(BASE_NS::string_view name) const override;
53
54 BASE_NS::vector<IProperty::Ptr> GetAllProperties() override;
55 BASE_NS::vector<IProperty::ConstPtr> GetAllProperties() const override;
56
57 public: // IObjectContext
58 IObjectRegistry& GetObjectRegistry() override;
59
60 private:
61 META_NS::IProxyObject* proxy_ { nullptr };
62 META_NS::IMetadata* metadata_ { nullptr };
63 IObject::WeakPtr target_;
64 };
65
66 } // namespace Internal
67
68 META_END_NAMESPACE()
69
70 #endif
71