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_OBJECT_TYPE_INFO_H 17 #define META_INTERFACE_OBJECT_TYPE_INFO_H 18 19 #include <base/containers/string_view.h> 20 #include <base/util/uid.h> 21 #include <core/plugin/intf_plugin.h> 22 23 #include <meta/interface/intf_object_factory.h> 24 25 META_BEGIN_NAMESPACE() 26 27 using GetFactoryType = IObjectFactory::Ptr (*)(); 28 29 /** 30 * @brief Type information for an IObject, to be used when registering a new object type. 31 */ 32 struct ObjectTypeInfo : public CORE_NS::ITypeInfo { 33 // NOLINTNEXTLINE(readability-identifier-naming) 34 static constexpr BASE_NS::Uid UID { "57b61777-e747-4281-9a06-a17414a07206" }; 35 const GetFactoryType GetFactory = nullptr; 36 }; 37 38 static bool operator==(const ObjectTypeInfo& lhs, const ObjectTypeInfo& rhs) 39 { 40 if (lhs.GetFactory && rhs.GetFactory) { 41 auto lhsF = lhs.GetFactory(); 42 auto rhsF = rhs.GetFactory(); 43 if (lhsF && rhsF) { 44 return lhsF->GetClassInfo() == rhsF->GetClassInfo(); 45 } 46 } 47 return false; 48 } 49 50 META_END_NAMESPACE() 51 52 #endif 53