本文整理汇总了C++中PluginSpec::setName方法的典型用法代码示例。如果您正苦于以下问题:C++ PluginSpec::setName方法的具体用法?C++ PluginSpec::setName怎么用?C++ PluginSpec::setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PluginSpec
的用法示例。
在下文中一共展示了PluginSpec::setName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addPlugin
/**
* @brief Add a plugin.
*
* @pre Needs to be a unique new name (use refname if you want to add the same module multiple times)
*
* Will automatically resolve virtual plugins to actual plugins.
*
* Also calls the checkconf function if provided by the plugin. The checkconf function has the
* following signature: int checkconf (Key * errorKey, KeySet * config) and allows a plugin to
* verify its configuration at mount time.
*
* @see resolveNeeds()
* @param plugin
*/
void BackendBuilder::addPlugin (PluginSpec const & plugin)
{
typedef int (*checkConfPtr) (ckdb::Key *, ckdb::KeySet *);
for (auto & p : toAdd)
{
if (p.getFullName () == plugin.getFullName ())
{
throw PluginAlreadyInserted (plugin.getFullName ());
}
}
PluginSpec newPlugin = plugin;
// if the plugin is actually a provider use it (otherwise we will get our name back):
PluginSpec provides = pluginDatabase->lookupProvides (plugin.getName ());
if (provides.getName () != newPlugin.getName ())
{
// keep our config and refname
newPlugin.setName (provides.getName ());
newPlugin.appendConfig (provides.getConfig ());
}
// call plugin's checkconf function (if provided)
// this enables a plugin to verify its configuration at mount time
checkConfPtr checkConfFunction = reinterpret_cast<checkConfPtr> (pluginDatabase->getSymbol (newPlugin, "checkconf"));
if (checkConfFunction)
{
ckdb::Key * errorKey = ckdb::keyNew (0);
// merge plugin config and backend config together
ckdb::KeySet * pluginConfig = newPlugin.getConfig ().dup ();
ckdb::ksAppend (pluginConfig, backendConf.getKeySet ());
// call the plugin's checkconf function
int checkResult = checkConfFunction (errorKey, pluginConfig);
if (checkResult == -1)
{
ckdb::ksDel (pluginConfig);
throw PluginConfigInvalid (errorKey);
}
else if (checkResult == 1)
{
// separate plugin config from the backend config
ckdb::Key * backendParent = ckdb::keyNew ("system/", KEY_END);
ckdb::KeySet * newBackendConfig = ckdb::ksCut (pluginConfig, backendParent);
// take over the new configuration
KeySet modifiedPluginConfig = KeySet (pluginConfig);
KeySet modifiedBackendConfig = KeySet (newBackendConfig);
newPlugin.setConfig (modifiedPluginConfig);
setBackendConfig (modifiedBackendConfig);
ckdb::keyDel (backendParent);
}
else
{
ckdb::ksDel (pluginConfig);
}
ckdb::keyDel (errorKey);
}
toAdd.push_back (newPlugin);
sort ();
}