当前位置: 首页>>代码示例>>C++>>正文


C++ PeripheralAddonPtr::CreateAddon方法代码示例

本文整理汇总了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;
}
开发者ID:0xheart0,项目名称:xbmc,代码行数:16,代码来源:PeripheralBusAddon.cpp

示例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);
  }
}
开发者ID:Arcko,项目名称:xbmc,代码行数:62,代码来源:PeripheralBusAddon.cpp


注:本文中的PeripheralAddonPtr::CreateAddon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。