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