IVGCVSW-5855 Refactor the reporting of capabilities from backends

Signed-off-by: Finn Williams <Finn.Williams@arm.com>
Change-Id: I05fc331a8e91bdcb6b8a2f32cfb555060fc5d797
diff --git a/include/armnn/BackendHelper.hpp b/include/armnn/BackendHelper.hpp
index 5eadab5..527d865 100644
--- a/include/armnn/BackendHelper.hpp
+++ b/include/armnn/BackendHelper.hpp
@@ -6,6 +6,7 @@
 #pragma once
 
 #include <armnn/BackendId.hpp>
+#include <armnn/BackendOptions.hpp>
 #include <armnn/backends/ILayerSupport.hpp>
 #include <armnn/Types.hpp>
 
@@ -436,7 +437,32 @@
 /// Convenience function to retrieve the ILayerSupportHandle for a backend
 LayerSupportHandle GetILayerSupportByBackendId(const armnn::BackendId& backend);
 
+/// Convenience function to check if a capability exists in a BackendCapabilites struct
+bool HasCapability(const std::string& name,const BackendCapabilities& capabilities);
+
+/// Convenience function to check if a capability exists in a backend
+bool HasCapability(const std::string& name, const armnn::BackendId& backend);
+
+/// Convenience function to check if a given capability matches a  capability in a BackendCapabilities struct
+bool HasCapability(const BackendOptions::BackendOption& capability, const BackendCapabilities& capabilities);
+
+/// Convenience function to check if a given capability matches a  capability in a backend
+bool HasCapability(const BackendOptions::BackendOption& backendOption, const armnn::BackendId& backend);
+
+/// Returns a BackendCapability if the backend lists the capability
+/// The BackendCapability must then be inspected to check whether or not that BackendCapability is supported
+/// Otherwise returns an EmptyOptional if the BackendCapability is unlisted
+Optional<const BackendOptions::BackendOption> GetCapability(const std::string& backendCapabilityName,
+                                                            const BackendCapabilities& capabilities);
+
+/// Returns a BackendCapability if the backend lists the capability
+/// The BackendCapability must then be inspected to check whether or not that BackendCapability is supported
+/// Otherwise returns an EmptyOptional if the BackendCapability is unlisted
+Optional<const BackendOptions::BackendOption> GetCapability(const std::string& backendCapabilityName,
+                                                            const armnn::BackendId& backend);
+
 /// Convenience function to check a capability on a backend
+ARMNN_DEPRECATED_MSG("This function has been deprecated in favour of GetBackendCapability")
 bool IsCapabilitySupported(const armnn::BackendId& backend, armnn::BackendCapability capability);
 
 }
diff --git a/include/armnn/BackendOptions.hpp b/include/armnn/BackendOptions.hpp
index b705f41..b8bf8f5 100644
--- a/include/armnn/BackendOptions.hpp
+++ b/include/armnn/BackendOptions.hpp
@@ -15,6 +15,7 @@
 using NetworkOptions = std::vector<BackendOptions>;
 
 using ModelOptions = std::vector<BackendOptions>;
+using BackendCapabilities = BackendOptions;
 
 /// Struct for the users to pass backend specific options
 struct BackendOptions
diff --git a/include/armnn/backends/IBackendInternal.hpp b/include/armnn/backends/IBackendInternal.hpp
index 135d279..b8edfe1 100644
--- a/include/armnn/backends/IBackendInternal.hpp
+++ b/include/armnn/backends/IBackendInternal.hpp
@@ -178,7 +178,16 @@
     /// Returns the version of the Backend API
     static constexpr BackendVersion GetApiVersion() { return BackendVersion(1, 0); }
 
+    /// Returns a BackendCapability if the backend lists the capability
+    /// The BackendCapability must then be inspected to check whether or not that BackendCapability is supported
+    /// Otherwise returns an EmptyOptional if the BackendCapability is unlisted
+    virtual BackendCapabilities GetCapabilities() const
+    {
+        return BackendCapabilities("IBackendInternal NullCapabilities");
+    };
+
     /// Returns true if backend support the capability false otherwise
+    ARMNN_DEPRECATED_MSG("This function has been deprecated in favour of GetCapability")
     virtual bool HasCapability(BackendCapability /*capabilityClass*/) const { return false; }
 };