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