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 #ifndef META_INTERFACE_OBJECT_FACTORY_H 16 #define META_INTERFACE_OBJECT_FACTORY_H 17 18 #include <meta/interface/static_object_metadata.h> 19 20 #if defined(GetClassInfo) 21 #undef GetClassInfo 22 #endif 23 24 META_BEGIN_NAMESPACE() 25 26 class IObject; 27 28 using Interfaces = BASE_NS::vector<BASE_NS::Uid>; 29 30 META_REGISTER_INTERFACE(IClassInfo, "2f8dc0eb-2d1b-47d5-aacb-47b824d0339d") 31 META_REGISTER_INTERFACE(IObjectFactory, "57f8ae84-3ad1-4923-aede-ef7bab852186") 32 33 /** 34 * @brief The IObjectInfo interface defines an interface for getting the metadata for a class. 35 */ 36 class IClassInfo : public CORE_NS::IInterface { 37 META_INTERFACE(CORE_NS::IInterface, IClassInfo) 38 public: 39 /** 40 * @brief Get class info for the constructed object type. 41 */ 42 virtual const ClassInfo& GetClassInfo() const = 0; 43 /** 44 * @brief Get static meta data for class (properties, events, functions) 45 */ 46 virtual const StaticObjectMetadata& GetClassStaticMetadata() const = 0; 47 /** 48 * @brief Get interfaces the constructed type implements. 49 */ 50 virtual const Interfaces& GetClassInterfaces() const = 0; 51 }; 52 53 /** 54 * @brief The IObjectFactory interface defines a factory interface used by the object and class 55 * registry for managing and instantiating classes which implement IObject. 56 */ 57 class IObjectFactory : public IClassInfo { 58 META_INTERFACE(IClassInfo, IObjectFactory) 59 public: 60 /** 61 * @brief Construct object. This is called by object registry when creating class instances, 62 * and should never be called by the user directly, as the returned object is not fully 63 * constructed yet. 64 */ 65 virtual BASE_NS::shared_ptr<IObject> CreateInstance() const = 0; 66 }; 67 68 META_END_NAMESPACE() 69 70 #endif 71