comparison plugin/FeatureExtractionPluginFactory.cpp @ 1148:9cdb4206aceb 3.0-integration

Check for plugin loadability before trying to load in the main process (POSIX only so far)
author Chris Cannam
date Mon, 11 Jan 2016 14:18:56 +0000
parents bff23ef9407e
children afed8be79032
comparison
equal deleted inserted replaced
1147:bff23ef9407e 1148:9cdb4206aceb
134 134
135 return candidates; 135 return candidates;
136 } 136 }
137 137
138 vector<QString> 138 vector<QString>
139 FeatureExtractionPluginFactory::winnowPluginCandidates(vector<QString> candidates)
140 {
141 vector<QString> good, bad;
142 vector<PluginLoadStatus> badStatuses;
143
144 for (QString c: candidates) {
145
146 PluginLoadStatus status =
147 TestPluginLoadability(c, "vampGetPluginDescriptor");
148
149 if (status == PluginLoadOK) {
150 good.push_back(c);
151 } else if (status == UnknownPluginLoadStatus) {
152 cerr << "WARNING: Unknown load status for plugin candidate \""
153 << c << "\", continuing" << endl;
154 good.push_back(c);
155 } else {
156 bad.push_back(c);
157 badStatuses.push_back(status);
158 }
159 }
160
161 if (!bad.empty()) {
162 QString warningMessage = "<b>Failed to load plugins</b></p>Failed to load one or more plugin libraries:</p><ul>\n";
163 for (int i = 0; i < bad.size(); ++i) {
164 QString m;
165 if (badStatuses[i] == PluginLoadFailedToLoadLibrary) {
166 m = "Failed to load library";
167 } else if (badStatuses[i] == PluginLoadFailedToFindDescriptor) {
168 m = "Failed to query plugins from library after loading";
169 } else if (badStatuses[i] == PluginLoadFailedElsewhere) {
170 m = "Unknown failure";
171 } else {
172 m = "Success: internal error?";
173 }
174 warningMessage += QString("<li>%1 (%2)</li>\n")
175 .arg(bad[i])
176 .arg(m);
177 }
178 warningMessage += "</ul>";
179 cerr << warningMessage; //!!! for now!
180 }
181 return good;
182 }
183
184 vector<QString>
139 FeatureExtractionPluginFactory::getPluginIdentifiers() 185 FeatureExtractionPluginFactory::getPluginIdentifiers()
140 { 186 {
141 Profiler profiler("FeatureExtractionPluginFactory::getPluginIdentifiers"); 187 Profiler profiler("FeatureExtractionPluginFactory::getPluginIdentifiers");
142 188
143 vector<QString> rv; 189 vector<QString> rv;
144 vector<QString> candidates = getPluginCandidateFiles(); 190 vector<QString> candidates = winnowPluginCandidates(getPluginCandidateFiles());
145 191
146 for (QString soname : candidates) { 192 for (QString soname : candidates) {
147 193
148 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE 194 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
149 SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: trying potential library " << soname << endl; 195 SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: trying potential library " << soname << endl;
150 #endif 196 #endif