| 283 | } |
| 284 | |
| 285 | bool |
| 286 | Plugin::unload(void) |
| 287 | { |
| 288 | if (this->m_loaded) { |
| 289 | if (!this->canBeUnloaded()) { |
| 290 | SU_ERROR( |
| 291 | "%s: plugin cannot be loaded (plugin in use)\n", |
| 292 | this->m_path.c_str()); |
| 293 | return false; |
| 294 | } |
| 295 | |
| 296 | auto p = this->m_factorySet.begin(); |
| 297 | |
| 298 | // Erase and unregister all factories globally |
| 299 | while (p != this->m_factorySet.end()) { |
| 300 | FeatureFactory *ref = *p; |
| 301 | if (!ref->unregisterGlobally()) { |
| 302 | SU_ERROR( |
| 303 | "%s: plugin cannot be loaded (failed to unregister global references to %s)\n", |
| 304 | this->m_path.c_str(), |
| 305 | ref->name()); |
| 306 | return false; |
| 307 | } |
| 308 | |
| 309 | // Erase and get next. It is important to do this before deleting |
| 310 | // the object. |
| 311 | p = this->m_factorySet.erase(p); |
| 312 | |
| 313 | delete ref; |
| 314 | } |
| 315 | |
| 316 | this->m_loaded = false; |
| 317 | } |
| 318 | |
| 319 | return true; |
| 320 | } |
| 321 | |
| 322 | bool |
| 323 | Plugin::registerFactory(FeatureFactory *factory) |
no test coverage detected