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
25CORE_BEGIN_NAMESPACE()
26using BASE_NS::string_view;
27using BASE_NS::Uid;
28
29// Engine factory
30IEngine::Ptr CreateEngine(EngineCreateInfo const& createInfo);
31
32IEngine::Ptr EngineFactory::Create(const EngineCreateInfo& engineCreateInfo)
33{
34    return IEngine::Ptr { CreateEngine(engineCreateInfo) };
35}
36
37Uid EngineFactory::GetClassUid() const
38{
39    return UID_ENGINE_FACTORY;
40}
41
42string_view EngineFactory::GetClassName() const
43{
44    return "EngineFactory";
45}
46
47const 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
58IInterface* 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
69void EngineFactory::Ref() {}
70
71void EngineFactory::Unref() {}
72CORE_END_NAMESPACE()
73