comparison 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
comparison
equal deleted inserted replaced
1374:8db84bd61eaa 1375:da5f4d37988d
52 void log(std::string message) const override { 52 void log(std::string message) const override {
53 SVDEBUG << "PiperVampPluginFactory: " << message << endl; 53 SVDEBUG << "PiperVampPluginFactory: " << message << endl;
54 } 54 }
55 }; 55 };
56 56
57 PiperVampPluginFactory::PiperVampPluginFactory(std::initializer_list<QString> servers) :
58 m_logger(new Logger)
59 {
60 HelperExecPath hep(HelperExecPath::AllInstalled);
61
62 for (auto server: servers) {
63 for (auto platformHelper: hep.getHelperExecutables(server))
64 m_servers.push_back(platformHelper);
65 }
66
67 for (auto n: m_servers) {
68 SVDEBUG << "NOTE: PiperVampPluginFactory: Found server: "
69 << n.executable << endl;
70 }
71
72 if (m_servers.empty()) {
73 SVDEBUG << "NOTE: No Piper Vamp servers found in installation;"
74 << " found none of the following:" << endl;
75 for (auto serverName: servers)
76 for (auto d: hep.getHelperCandidatePaths(serverName)) {
77 SVDEBUG << "NOTE: " << d << endl;
78 }
79 }
80 }
81
57 PiperVampPluginFactory::PiperVampPluginFactory() : 82 PiperVampPluginFactory::PiperVampPluginFactory() :
58 m_logger(new Logger) 83 PiperVampPluginFactory({"piper-vamp-simple-server"}) {}
59 {
60 QString serverName = "piper-vamp-simple-server";
61
62 HelperExecPath hep(HelperExecPath::AllInstalled);
63 m_servers = hep.getHelperExecutables(serverName);
64
65 for (auto n: m_servers) {
66 SVDEBUG << "NOTE: PiperVampPluginFactory: Found server: "
67 << n.executable << endl;
68 }
69
70 if (m_servers.empty()) {
71 SVDEBUG << "NOTE: No Piper Vamp servers found in installation;"
72 << " found none of the following:" << endl;
73 for (auto d: hep.getHelperCandidatePaths(serverName)) {
74 SVDEBUG << "NOTE: " << d << endl;
75 }
76 }
77 }
78 84
79 PiperVampPluginFactory::~PiperVampPluginFactory() 85 PiperVampPluginFactory::~PiperVampPluginFactory()
80 { 86 {
81 delete m_logger; 87 delete m_logger;
82 } 88 }