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_STATIC_OBJECT_METADATA_H
17 #define META_INTERFACE_STATIC_OBJECT_METADATA_H
18 
19 #include <meta/base/namespace.h>
20 #include <meta/base/types.h>
21 #include <meta/interface/intf_call_context.h>
22 #include <meta/interface/intf_event.h>
23 #include <meta/interface/intf_function.h>
24 #include <meta/interface/property/intf_property.h>
25 
META_BEGIN_NAMESPACE()26 META_BEGIN_NAMESPACE()
27 
28 namespace Internal {
29 using PCtor = IProperty::Ptr();
30 using PMemberInit = bool(void*, const IProperty::Ptr&);
31 } // namespace Internal
32 /// Static metadata for property
33 struct PropertyMetadata {
34     /// Name of the property
35     BASE_NS::string_view name;
36     /// Info of the interface where this property comes from
37     InterfaceInfo interfaceInfo;
38     /// Flags of the property
39     ObjectFlagBitsValue flags;
40     /// Uid of the property type
41     BASE_NS::Uid typeId;
42     /// Function to create property of this type
43     Internal::PCtor* create {};
44     /// Function to initialise a property for specific object instance.
45     Internal::PMemberInit* init {};
46 };
47 
48 namespace Internal {
49 using ECtor = IEvent::Ptr();
50 using EMemberInit = bool(void*, const IEvent::Ptr&);
51 } // namespace Internal
52 /// Static metadata for event
53 struct EventMetadata {
54     // Name of the event
55     BASE_NS::string_view name;
56     /// Info of the interface where this property comes from
57     InterfaceInfo interfaceInfo;
58     /// Uid of the event type
59     BASE_NS::Uid typeId;
60     /// Function to create event of this type
61     Internal::ECtor* create {};
62     /// Function to initialise a event for specific object instance
63     Internal::EMemberInit* init {};
64 };
65 
66 namespace Internal {
67 using FCtor = IFunction::Ptr(void*);
68 using FContext = ICallContext::Ptr();
69 } // namespace Internal
70 
71 /// Static metadata for function
72 struct FunctionMetadata {
73     /// Name of the function
74     BASE_NS::string_view name;
75     /// Info of the interface where this property comes from
76     InterfaceInfo interfaceInfo;
77     /// Function to create function of this type
78     Internal::FCtor* create {};
79     Internal::FContext* context {};
80 };
81 
82 /// Static metadata for single object class
83 struct StaticObjectMetadata {
84     const META_NS::ClassInfo& classInfo;
85     const StaticObjectMetadata* baseclass {};
86     BASE_NS::vector<PropertyMetadata> properties;
87     BASE_NS::vector<EventMetadata> events;
88     BASE_NS::vector<FunctionMetadata> functions;
89 };
90 
91 META_END_NAMESPACE()
92 
93 #endif
94