comparison 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
comparison
equal deleted inserted replaced
1375:da5f4d37988d 1376:d9511f9e04d7
32 * separate process using Piper protocol. 32 * separate process using Piper protocol.
33 */ 33 */
34 class PiperVampPluginFactory : public FeatureExtractionPluginFactory 34 class PiperVampPluginFactory : public FeatureExtractionPluginFactory
35 { 35 {
36 public: 36 public:
37 using ServerName = std::string;
38 using DesiredSubset = std::vector<std::string>;
39 struct DesiredExtractors
40 {
41 DesiredExtractors() : allAvailable(false) {} // filtered, but invalid, by default (from should not be empty)
42
43 DesiredExtractors(DesiredSubset subset)
44 : allAvailable(subset.empty()), from(subset) {} // if empty assume all available are wanted, can populate struct manually if not
45
46 bool allAvailable; // used to disambiguate an empty filter list from wanting all available extractors, client code should inspect both to determine validity
47 DesiredSubset from; // this should only be populated if allAvailable is false
48 };
49
50 struct ServerDescription
51 {
52 ServerDescription(ServerName n)
53 : name(n), hasDesiredExtractors(false) {} // fall back to populating using PluginScan internally
54 ServerDescription(ServerName n, DesiredSubset desired)
55 : name(n), hasDesiredExtractors(true), extractors(desired) {}
56 ServerName name;
57 bool hasDesiredExtractors; // indicates whether to override the ListRequest made internally
58 DesiredExtractors extractors; // for populating the from field in a ListRequest
59 };
60
37 PiperVampPluginFactory(); 61 PiperVampPluginFactory();
38 PiperVampPluginFactory(std::initializer_list<QString> servers); 62 PiperVampPluginFactory(std::initializer_list<ServerDescription> servers);
63
64 virtual void setDesiredExtractors(ServerName name, DesiredExtractors extractors);
65
39 virtual ~PiperVampPluginFactory(); 66 virtual ~PiperVampPluginFactory();
40 67
41 virtual std::vector<QString> getPluginIdentifiers(QString &errorMessage) 68 virtual std::vector<QString> getPluginIdentifiers(QString &errorMessage)
42 override; 69 override;
43 70
54 QMutex m_mutex; 81 QMutex m_mutex;
55 QList<HelperExecPath::HelperExec> m_servers; // executable file paths 82 QList<HelperExecPath::HelperExec> m_servers; // executable file paths
56 std::map<QString, QString> m_origins; // plugin identifier -> server path 83 std::map<QString, QString> m_origins; // plugin identifier -> server path
57 std::map<QString, piper_vamp::PluginStaticData> m_pluginData; // identifier -> data 84 std::map<QString, piper_vamp::PluginStaticData> m_pluginData; // identifier -> data
58 std::map<QString, QString> m_taxonomy; // identifier -> category string 85 std::map<QString, QString> m_taxonomy; // identifier -> category string
86 std::map<ServerName, DesiredExtractors> m_overrideDesiredExtractors;
59 87
60 void populate(QString &errorMessage); 88 void populate(QString &errorMessage);
61 void populateFrom(const HelperExecPath::HelperExec &, QString &errorMessage); 89 void populateFrom(const HelperExecPath::HelperExec &, QString &errorMessage);
62 90
63 class Logger; 91 class Logger;