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 CORE_ENGINE_FACTORY_H
17 #define CORE_ENGINE_FACTORY_H
18 
19 #include <cstdint>
20 
21 #include <base/containers/string_view.h>
22 #include <base/util/uid.h>
23 #include <core/intf_engine.h>
24 #include <core/namespace.h>
25 #include <core/plugin/intf_class_info.h>
26 
27 CORE_BEGIN_NAMESPACE()
28 class IInterface;
29 struct EngineCreateInfo;
30 class EngineFactory final : public IEngineFactory, public IClassInfo {
31 public:
32     EngineFactory() = default;
33     ~EngineFactory() override = default;
34 
35     // IInterface
36     const IInterface* GetInterface(const BASE_NS::Uid& uid) const override;
37     IInterface* GetInterface(const BASE_NS::Uid& uid) override;
38     void Ref() override;
39     void Unref() override;
40 
41     // IClassInfo
42     BASE_NS::Uid GetClassUid() const override;
43     BASE_NS::string_view GetClassName() const override;
44 
45     // IEngineFactory
46     IEngine::Ptr Create(const EngineCreateInfo& engineCreateInfo) override;
47     uint32_t refcnt_ { 0 };
48 };
49 CORE_END_NAMESPACE()
50 
51 #endif // CORE_ENGINE_FACTORY_H
52