Sese Framework
2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
ClassFactory.h
Go to the documentation of this file.
1
// Copyright 2024 libsese
2
//
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
22
#pragma once
23
24
#include "
sese/plugin/BaseClass.h
"
25
#include "
sese/util/ErrorCode.h
"
26
#include "
sese/util/Result.h
"
27
28
#include <map>
29
#include <string>
30
#include <typeinfo>
31
#include <functional>
32
33
namespace
sese::plugin
{
34
35
// GCOVR_EXCL_START
36
38
class
ClassFactory
{
39
public
:
41
struct
RegisterInfo
{
42
const
std::type_info *
info
;
43
std::function<std::shared_ptr<BaseClass>()>
builder
;
44
};
45
using
RegisterInfoMapType
= std::map<std::string, RegisterInfo>;
46
47
ClassFactory
() noexcept = default;
48
ClassFactory
(
ClassFactory
&&class_factory) = delete;
49
ClassFactory
(const
ClassFactory
&class_factory) = delete;
50
virtual ~
ClassFactory
() = default;
51
52
virtual
void
init
() = 0;
53
58
BaseClass
::Ptr
createClassWithName
(const std::
string
&
id
) noexcept;
59
60
Result
<
BaseClass
::Ptr,
ErrorCode
>
createClassWithNameEx
(const std::
string
&
id
) noexcept;
61
64
const
RegisterInfoMapType
&
getRegisterClassInfo
() noexcept;
65
66
protected:
67
RegisterInfoMapType
infoMap
{};
68
};
69
70
// GCOVR_EXCL_STOP
71
72
}
// namespace sese::plugin
sese
plugin
ClassFactory.h
Generated on Tue Jan 7 2025 15:49:06 for Sese Framework by
1.11.0