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 #include "engine_factory.h"
17 
18 #include <base/containers/string_view.h>
19 #include <base/util/uid.h>
20 #include <core/implementation_uids.h>
21 #include <core/intf_engine.h>
22 #include <core/namespace.h>
23 #include <core/plugin/intf_class_info.h>
24 
25 CORE_BEGIN_NAMESPACE()
26 using BASE_NS::string_view;
27 using BASE_NS::Uid;
28 
29 // Engine factory
30 IEngine::Ptr CreateEngine(EngineCreateInfo const& createInfo);
31 
Create(const EngineCreateInfo & engineCreateInfo)32 IEngine::Ptr EngineFactory::Create(const EngineCreateInfo& engineCreateInfo)
33 {
34     return IEngine::Ptr { CreateEngine(engineCreateInfo) };
35 }
36 
GetClassUid() const37 Uid EngineFactory::GetClassUid() const
38 {
39     return UID_ENGINE_FACTORY;
40 }
41 
GetClassName() const42 string_view EngineFactory::GetClassName() const
43 {
44     return "EngineFactory";
45 }
46 
GetInterface(const Uid & uid) const47 const IInterface* EngineFactory::GetInterface(const Uid& uid) const
48 {
49     if ((uid == IEngineFactory::UID) || (uid == IInterface::UID)) {
50         return static_cast<const IEngineFactory*>(this);
51     }
52     if (uid == IClassInfo::UID) {
53         return static_cast<const IClassInfo*>(this);
54     }
55     return nullptr;
56 }
57 
GetInterface(const Uid & uid)58 IInterface* EngineFactory::GetInterface(const Uid& uid)
59 {
60     if ((uid == IEngineFactory::UID) || (uid == IInterface::UID)) {
61         return static_cast<IEngineFactory*>(this);
62     }
63     if (uid == IClassInfo::UID) {
64         return static_cast<IClassInfo*>(this);
65     }
66     return nullptr;
67 }
68 
Ref()69 void EngineFactory::Ref() {}
70 
Unref()71 void EngineFactory::Unref() {}
72 CORE_END_NAMESPACE()
73