-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperators.cpp
More file actions
48 lines (41 loc) · 1.8 KB
/
Copy pathoperators.cpp
File metadata and controls
48 lines (41 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved. */
#include "core/core.hpp"
namespace mlss
{
//=================================================================================================================
// OperatorRegistry implementation
//=================================================================================================================
// Static member definition
std::unordered_map<std::string, FactoryFunction> OperatorRegistry::registry;
//=================================================================================================================
void OperatorRegistry::registerType(const std::string& name, FactoryFunction factory)
{
registry[name] = factory;
}
//=================================================================================================================
std::unique_ptr<OperatorBase<void>> OperatorRegistry::create(const std::string& typeName)
{
auto it = registry.find(typeName);
if (it != registry.end())
{
return it->second();
}
return nullptr;
}
//=================================================================================================================
std::vector<std::string> OperatorRegistry::getRegisteredTypes()
{
std::vector<std::string> types;
types.reserve(registry.size());
for (const auto& [name, factory] : registry)
{
types.push_back(name);
}
return types;
}
//=================================================================================================================
bool OperatorRegistry::isTypeRegistered(const std::string& typeName)
{
return registry.find(typeName) != registry.end();
}
} // namespace mlss