void Plugins::checkStorage (Plugin & plugin) { if (plugin.findInfo ("storage", "provides")) { ++nrStoragePlugins; } if (nrStoragePlugins > 1) { --nrStoragePlugins; throw StoragePlugin (); } }
void Plugins::addPlugin (Plugin & plugin, std::string which) { if (!plugin.findInfo (which, "placements")) return; std::string stacking = plugin.lookupInfo ("stacking"); if (which == "postgetstorage" && stacking == "") { plugins[revPostGet--] = &plugin; return; } plugins[placementInfo[which].current++] = &plugin; }
void Plugins::checkResolver (Plugin & plugin) { if (plugin.findInfo ("resolver", "provides")) { ++nrResolverPlugins; } if (nrResolverPlugins > 1) { --nrResolverPlugins; throw ResolverPlugin (); } }
/** * @brief check if this plugin can be placed in the unfortunately * limited number of slots * * @param plugin the plugin to check * @param which placementInfo it is * * @retval true if it should be added * @retval false no placements (will not be added) */ bool Plugins::checkPlacement (Plugin &plugin, std::string which) { if (!plugin.findInfo(which, "placements")) return false; // nothing to check, won't be added anyway std::string stacking = plugin.lookupInfo("stacking"); if (which=="postgetstorage" && stacking == "") { if (revPostGet >= placementInfo["postgetstorage"].current) { return true; } std::ostringstream os; os << "Too many plugins!\n" "The plugin " << plugin.name() << " can't be positioned to position " << which << " anymore.\n" "Try to reduce the number of plugins!\n" "\n" "Failed because of stack overflow: cant place to " << revPostGet << " because " << placementInfo["postgetstorage"].current << " is larger (this slot is in use)." << endl; throw TooManyPlugins(os.str()); } if (placementInfo[which].current > placementInfo[which].max) { std::ostringstream os; os << "Too many plugins!\n" "The plugin " << plugin.name() << " can't be positioned to position " << which << " anymore.\n" "Try to reduce the number of plugins!\n" "\n" "Failed because " << which << " with " << placementInfo[which].current << " is larger than " << placementInfo[which].max << endl; throw TooManyPlugins(os.str()); } return true; }