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_IMETA_OBJECT_LIB_H 17 #define META_INTERFACE_IMETA_OBJECT_LIB_H 18 19 #include <core/log.h> 20 #include <core/namespace.h> 21 #include <core/plugin/intf_interface.h> 22 23 #include <meta/base/interface_macros.h> 24 #include <meta/base/namespace.h> 25 26 CORE_BEGIN_NAMESPACE() 27 struct SyncApi; 28 CORE_END_NAMESPACE() 29 30 META_BEGIN_NAMESPACE() 31 32 class IObjectRegistry; 33 class ITaskQueueRegistry; 34 class IBindingState; 35 class IAnimationController; 36 37 /** 38 * @brief Meta object library global access point for globally used objects. 39 */ 40 class IMetaObjectLib : public CORE_NS::IInterface { 41 META_INTERFACE(CORE_NS::IInterface, IMetaObjectLib, "6f4ba852-3a00-4bbd-82bf-c36fb657992e") 42 public: 43 virtual IObjectRegistry& GetObjectRegistry() const = 0; 44 virtual ITaskQueueRegistry& GetTaskQueueRegistry() const = 0; 45 virtual BASE_NS::shared_ptr<IAnimationController> GetAnimationController() const = 0; 46 virtual const CORE_NS::SyncApi& GetSyncApi() const = 0; 47 }; 48 49 /** 50 * @brief Get global IMetaObjectLib instance. 51 */ GetMetaObjectLib()52inline IMetaObjectLib& GetMetaObjectLib() 53 { 54 auto* instance = CORE_NS::GetInstance<IMetaObjectLib>(IMetaObjectLib::UID); 55 if (instance) { 56 return *instance; 57 } 58 CORE_LOG_F("Meta Object Lib not initialized"); 59 CORE_ASSERT(false); 60 abort(); 61 } 62 63 META_END_NAMESPACE() 64 65 #endif 66