diff plugin/PiperVampPluginFactory.h @ 1376:d9511f9e04d7 dev/refactor-piper-related

Introduce some POD structs for describing an external server application and the desired libraries to load from it, and disambiguating between empty list request and invalid list request. This allows for overriding PiperVampPluginFactory behaviour for using a PluginScan to populate the list request.
author Lucas Thompson <lucas.thompson@qmul.ac.uk>
date Fri, 10 Feb 2017 11:15:19 +0000
parents da5f4d37988d
children f1c4ca3ccaa3
line wrap: on
line diff
--- a/plugin/PiperVampPluginFactory.h	Thu Feb 09 14:32:07 2017 +0000
+++ b/plugin/PiperVampPluginFactory.h	Fri Feb 10 11:15:19 2017 +0000
@@ -34,8 +34,35 @@
 class PiperVampPluginFactory : public FeatureExtractionPluginFactory
 {
 public:
+    using ServerName = std::string;
+    using DesiredSubset = std::vector<std::string>;
+    struct DesiredExtractors 
+    {
+        DesiredExtractors() : allAvailable(false) {} // filtered, but invalid, by default (from should not be empty)
+        
+        DesiredExtractors(DesiredSubset subset) 
+            : allAvailable(subset.empty()), from(subset) {} // if empty assume all available are wanted, can populate struct manually if not
+        
+        bool allAvailable; // used to disambiguate an empty filter list from wanting all available extractors, client code should inspect both to determine validity 
+        DesiredSubset from; // this should only be populated if allAvailable is false
+    };
+    
+    struct ServerDescription 
+    {
+        ServerDescription(ServerName n) 
+            : name(n), hasDesiredExtractors(false) {} // fall back to populating using PluginScan internally
+        ServerDescription(ServerName n, DesiredSubset desired) 
+            : name(n), hasDesiredExtractors(true), extractors(desired) {}
+        ServerName name;
+        bool hasDesiredExtractors; // indicates whether to override the ListRequest made internally
+        DesiredExtractors extractors; // for populating the from field in a ListRequest
+    };
+    
     PiperVampPluginFactory();
-    PiperVampPluginFactory(std::initializer_list<QString> servers);
+    PiperVampPluginFactory(std::initializer_list<ServerDescription> servers);
+    
+    virtual void setDesiredExtractors(ServerName name, DesiredExtractors extractors);
+    
     virtual ~PiperVampPluginFactory();
 
     virtual std::vector<QString> getPluginIdentifiers(QString &errorMessage)
@@ -56,6 +83,7 @@
     std::map<QString, QString> m_origins; // plugin identifier -> server path
     std::map<QString, piper_vamp::PluginStaticData> m_pluginData; // identifier -> data
     std::map<QString, QString> m_taxonomy; // identifier -> category string
+    std::map<ServerName, DesiredExtractors> m_overrideDesiredExtractors;
 
     void populate(QString &errorMessage);
     void populateFrom(const HelperExecPath::HelperExec &, QString &errorMessage);