Skip to content

Commit

Permalink
Fixed mismatch if family is uppercase
Browse files Browse the repository at this point in the history
  • Loading branch information
wardru committed Oct 15, 2023
1 parent 0864374 commit 7ed47fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
13 changes: 8 additions & 5 deletions source/pza/core/device_factory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

using namespace pza;

std::map<std::string, device_factory::factory_function> device_factory::_factory_map = {
{ "bps", device_factory::allocate_device<bps> }
};

device::ptr device_factory::create_device(const std::string &family, const std::string &group, const std::string &name)
{
auto it = _factory_map.find(family);
if (it == _factory_map.end()) {
static std::map<std::string, device_factory::factory_function> factory_map = {
{ "bps", device_factory::allocate_device<bps> }
};
std::string family_lower = family;

std::transform(family_lower.begin(), family_lower.end(), family_lower.begin(), ::tolower);
auto it = factory_map.find(family_lower);
if (it == factory_map.end()) {
spdlog::error("Unknown device type {}", family);
return nullptr;
}
Expand Down
1 change: 0 additions & 1 deletion source/pza/core/device_factory.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ namespace pza

private:
using factory_function = std::function<device::ptr(const std::string &group, const std::string &name)>;
static std::map<std::string, factory_function> _factory_map;
};
};

0 comments on commit 7ed47fa

Please sign in to comment.