• 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_STATIC_OBJECT_METADATA_H
17 #define META_INTERFACE_STATIC_OBJECT_METADATA_H
18 
19 #include <meta/base/namespace.h>
20 #include <meta/base/shared_ptr.h>
21 #include <meta/base/types.h>
22 
23 META_BEGIN_NAMESPACE()
24 
25 class IOwner;
26 class IAny;
27 
28 struct StaticMetadata;
29 
30 namespace Internal {
31 using MetadataCtor = BASE_NS::shared_ptr<CORE_NS::IInterface>(
32     const BASE_NS::shared_ptr<IOwner>&, const StaticMetadata& data);
33 using MetaValue = BASE_NS::shared_ptr<IAny>();
34 } // namespace Internal
35 
36 enum class MetadataType : uint8_t { UNKNOWN = 0, PROPERTY = 1, EVENT = 2, FUNCTION = 4 };
37 
38 inline MetadataType operator|(MetadataType a, MetadataType b)
39 {
40     return MetadataType(uint8_t(a) | uint8_t(b));
41 }
42 
43 struct StaticMetadata {
44     const MetadataType type {};
45     const InterfaceInfo interfaceInfo {};
46     const char* const name {};
47     Internal::MetadataCtor* const create {};
48     Internal::MetaValue* const runtimeValue {};
49     const void* const data {};
50 };
51 
52 /// Static metadata for single object class
53 struct StaticObjectMetadata {
54     const ClassInfo* classInfo {};
55     const StaticObjectMetadata* baseclass {}; // direct base class
56     const StaticObjectMetadata* aggregate {}; // aggregate "base" class
57     const StaticMetadata* metadata {};
58     const size_t size {};
59 };
60 
61 META_END_NAMESPACE()
62 
63 #endif
64