aboutsummaryrefslogtreecommitdiff
path: root/src/backends/BackendRegistry.cpp
diff options
context:
space:
mode:
authorDavid Beck <david.beck@arm.com>2018-10-10 15:11:44 +0100
committerMatthew Bentham <matthew.bentham@arm.com>2018-10-22 16:57:53 +0100
commit9df2d951616e3d76b67a9852d5324de96633f0f9 (patch)
tree37a57a98ef8aafba748d332bfc686e2b022398d6 /src/backends/BackendRegistry.cpp
parent6b779f0e437127bfa71a529e9b848b5e41683ab8 (diff)
downloadarmnn-9df2d951616e3d76b67a9852d5324de96633f0f9.tar.gz
IVGCVSW-1952 : add BackendId class to prepare for the replacement of Compute enum
!armnn:152674 Change-Id: I1bcdfdfbfb73e502d58f35717e2558e24651013c
Diffstat (limited to 'src/backends/BackendRegistry.cpp')
-rw-r--r--src/backends/BackendRegistry.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/backends/BackendRegistry.cpp b/src/backends/BackendRegistry.cpp
index 68336c45b9..a5e9f0e1d9 100644
--- a/src/backends/BackendRegistry.cpp
+++ b/src/backends/BackendRegistry.cpp
@@ -15,22 +15,22 @@ BackendRegistry& BackendRegistry::Instance()
return instance;
}
-void BackendRegistry::Register(const std::string& name, FactoryFunction factory)
+void BackendRegistry::Register(const BackendId& id, FactoryFunction factory)
{
- if (m_BackendFactories.count(name) > 0)
+ if (m_BackendFactories.count(id) > 0)
{
- throw InvalidArgumentException(name + " already registered as backend");
+ throw InvalidArgumentException(std::string(id) + " already registered as backend");
}
- m_BackendFactories[name] = factory;
+ m_BackendFactories[id] = factory;
}
-BackendRegistry::FactoryFunction BackendRegistry::GetFactory(const std::string& name) const
+BackendRegistry::FactoryFunction BackendRegistry::GetFactory(const BackendId& id) const
{
- auto it = m_BackendFactories.find(name);
+ auto it = m_BackendFactories.find(id);
if (it == m_BackendFactories.end())
{
- throw InvalidArgumentException(name + " has no backend factory registered");
+ throw InvalidArgumentException(std::string(id) + " has no backend factory registered");
}
return it->second;
@@ -42,4 +42,14 @@ void BackendRegistry::Swap(BackendRegistry::FactoryStorage& other)
std::swap(instance.m_BackendFactories, other);
}
+BackendIdSet BackendRegistry::GetBackendIds() const
+{
+ BackendIdSet result;
+ for (const auto& it : m_BackendFactories)
+ {
+ result.insert(it.first);
+ }
+ return result;
}
+
+} // namespace armnn