diff plugin/PiperVampPluginFactory.cpp @ 1375:da5f4d37988d dev/refactor-piper-related

Invert control, injecting a server path on construction. Also add initializer_list constructor for multiple servers.
author Lucas Thompson <lucas.thompson@qmul.ac.uk>
date Thu, 09 Feb 2017 14:32:07 +0000
parents 54fabf5aceb8
children d9511f9e04d7
line wrap: on
line diff
--- a/plugin/PiperVampPluginFactory.cpp	Tue Feb 07 14:55:19 2017 +0000
+++ b/plugin/PiperVampPluginFactory.cpp	Thu Feb 09 14:32:07 2017 +0000
@@ -54,28 +54,34 @@
     }
 };
 
-PiperVampPluginFactory::PiperVampPluginFactory() :
+PiperVampPluginFactory::PiperVampPluginFactory(std::initializer_list<QString> servers) :
     m_logger(new Logger)
 {
-    QString serverName = "piper-vamp-simple-server";
+    HelperExecPath hep(HelperExecPath::AllInstalled);
 
-    HelperExecPath hep(HelperExecPath::AllInstalled);
-    m_servers = hep.getHelperExecutables(serverName);
+    for (auto server: servers) {
+        for (auto platformHelper: hep.getHelperExecutables(server))
+            m_servers.push_back(platformHelper);
+    }
 
     for (auto n: m_servers) {
-        SVDEBUG << "NOTE: PiperVampPluginFactory: Found server: "
+        SVDEBUG << "NOTE: PiperVampPluginFactory: Found server: " 
                 << n.executable << endl;
     }
-    
+
     if (m_servers.empty()) {
-        SVDEBUG << "NOTE: No Piper Vamp servers found in installation;"
+        SVDEBUG << "NOTE: No Piper Vamp servers found in installation;" 
                 << " found none of the following:" << endl;
-        for (auto d: hep.getHelperCandidatePaths(serverName)) {
-            SVDEBUG << "NOTE: " << d << endl;
-        }
+        for (auto serverName: servers)
+            for (auto d: hep.getHelperCandidatePaths(serverName)) {
+                SVDEBUG << "NOTE: " << d << endl;
+            }
     }
 }
 
+PiperVampPluginFactory::PiperVampPluginFactory() :
+    PiperVampPluginFactory({"piper-vamp-simple-server"}) {}
+
 PiperVampPluginFactory::~PiperVampPluginFactory()
 {
     delete m_logger;