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_SRC_META_OBJECT_LIB_H 17 #define META_SRC_META_OBJECT_LIB_H 18 19 #include <mutex> 20 21 #include <meta/base/interface_macros.h> 22 #include <meta/interface/animation/intf_animation_controller.h> 23 #include <meta/interface/builtin_objects.h> 24 #include <meta/interface/intf_meta_object_lib.h> 25 #include <meta/interface/threading/primitive_api.h> 26 27 #include "object_registry.h" 28 META_BEGIN_NAMESPACE()29META_BEGIN_NAMESPACE() 30 31 class MetaObjectLib : public IMetaObjectLib { 32 public: 33 META_IMPLEMENT_REF_COUNT_NO_ONDESTROY() 34 35 const IInterface* GetInterface(const BASE_NS::Uid& uid) const override; 36 IInterface* GetInterface(const BASE_NS::Uid& uid) override; 37 38 MetaObjectLib(); 39 ~MetaObjectLib() override; 40 41 META_NO_COPY_MOVE(MetaObjectLib) 42 43 void Initialize(); 44 void Uninitialize(); 45 46 IObjectRegistry& GetObjectRegistry() const override; 47 ITaskQueueRegistry& GetTaskQueueRegistry() const override; 48 IAnimationController::Ptr GetAnimationController() const override; 49 const CORE_NS::SyncApi& GetSyncApi() const override; 50 51 private: 52 mutable std::once_flag animInit_; 53 54 // the registry is still requested when destroyed, so we keep plain pointer to circumvent that. 55 ObjectRegistry* registry_ {}; 56 mutable IAnimationController::Ptr animationController_; 57 const CORE_NS::SyncApi sapi_; 58 }; 59 60 META_END_NAMESPACE() 61 62 #endif 63