本文整理汇总了C++中PeripheralAddonPtr::CreateAddon方法的典型用法代码示例。如果您正苦于以下问题:C++ PeripheralAddonPtr::CreateAddon方法的具体用法?C++ PeripheralAddonPtr::CreateAddon怎么用?C++ PeripheralAddonPtr::CreateAddon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PeripheralAddonPtr
的用法示例。
在下文中一共展示了PeripheralAddonPtr::CreateAddon方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RequestRestart
bool CPeripheralBusAddon::RequestRestart(ADDON::AddonPtr addon, bool datachanged)
{
// make sure this is a peripheral addon
PeripheralAddonPtr peripheralAddon = std::dynamic_pointer_cast<CPeripheralAddon>(addon);
if (peripheralAddon == nullptr)
return false;
if (peripheralAddon->CreateAddon() != ADDON_STATUS_OK)
{
CSingleLock lock(m_critSection);
m_addons.erase(std::remove(m_addons.begin(), m_addons.end(), peripheralAddon), m_addons.end());
m_failedAddons.push_back(peripheralAddon);
}
return true;
}
示例2: UpdateAddons
void CPeripheralBusAddon::UpdateAddons(void)
{
using namespace ADDON;
auto GetPeripheralAddonID = [](const PeripheralAddonPtr& addon) { return addon->ID(); };
auto GetAddonID = [](const BinaryAddonBasePtr& addon) { return addon->ID(); };
std::set<std::string> currentIds;
std::set<std::string> newIds;
std::set<std::string> added;
std::set<std::string> removed;
// Get new add-ons
BinaryAddonBaseList newAddons;
CServiceBroker::GetBinaryAddonManager().GetAddonInfos(newAddons, true, ADDON_PERIPHERALDLL);
std::transform(newAddons.begin(), newAddons.end(), std::inserter(newIds, newIds.end()), GetAddonID);
CSingleLock lock(m_critSection);
// Get current add-ons
std::transform(m_addons.begin(), m_addons.end(), std::inserter(currentIds, currentIds.end()), GetPeripheralAddonID);
std::transform(m_failedAddons.begin(), m_failedAddons.end(), std::inserter(currentIds, currentIds.end()), GetPeripheralAddonID);
// Differences
std::set_difference(newIds.begin(), newIds.end(), currentIds.begin(), currentIds.end(), std::inserter(added, added.end()));
std::set_difference(currentIds.begin(), currentIds.end(), newIds.begin(), newIds.end(), std::inserter(removed, removed.end()));
// Register new add-ons
for (const std::string& addonId : added)
{
CLog::Log(LOGDEBUG, "Add-on bus: Registering add-on %s", addonId.c_str());
auto GetAddon = [&addonId](const BinaryAddonBasePtr& addon) { return addon->ID() == addonId; };
BinaryAddonBaseList::iterator it = std::find_if(newAddons.begin(), newAddons.end(), GetAddon);
if (it != newAddons.end())
{
PeripheralAddonPtr newAddon = std::make_shared<CPeripheralAddon>(*it, m_manager);
if (newAddon)
{
bool bCreated;
{
CSingleExit exit(m_critSection);
bCreated = newAddon->CreateAddon();
}
if (bCreated)
m_addons.emplace_back(std::move(newAddon));
else
m_failedAddons.emplace_back(std::move(newAddon));
}
}
}
// Destroy removed add-ons
for (const std::string& addonId : removed)
{
UnRegisterAddon(addonId);
}
}