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


C++ CPVRDatabase类代码示例

本文整理汇总了C++中CPVRDatabase的典型用法代码示例。如果您正苦于以下问题:C++ CPVRDatabase类的具体用法?C++ CPVRDatabase怎么用?C++ CPVRDatabase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CPVRDatabase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LoadFromClients

int CPVRChannels::LoadFromClients(bool bAddToDb /* = true */)
{
  CPVRDatabase *database = NULL;
  int iCurSize = size();

  if (bAddToDb)
  {
    database = g_PVRManager.GetTVDatabase();

    if (!database || !database->Open())
      return -1;
  }

  if (GetFromClients() == -1)
    return -1;

  SortByClientChannelNumber();
  ReNumberAndCheck();
  SearchAndSetChannelIcons();

  if (bAddToDb)
  {
    /* add all channels to the database */
    for (unsigned int ptr = 0; ptr < size(); ptr++)
      database->UpdateChannel(*at(ptr));

    database->Close();

    clear();

    return LoadFromDb(true);
  }

  return size() - iCurSize;
}
开发者ID:margro,项目名称:xbmc-antiquated,代码行数:35,代码来源:PVRChannels.cpp

示例2: Clear

bool CPVRChannelGroups::Load(void)
{
    CLog::Log(LOGDEBUG, "PVRChannelGroups - %s - loading all %s channel groups",
              __FUNCTION__, m_bRadio ? "radio" : "TV");

    Clear();

    /* create internal channel group */
    CPVRChannelGroupInternal *internalChannels = new CPVRChannelGroupInternal(m_bRadio);
    push_back(internalChannels);
    internalChannels->Load();

    /* load the other groups from the database */
    CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase();
    if (database->Open())
    {
        database->GetChannelGroupList(*this, m_bRadio);

        /* load group members */
        for (unsigned int iGroupPtr = 1; iGroupPtr < size(); iGroupPtr++)
            at(iGroupPtr)->Load();

        database->Close();
    }

    CLog::Log(LOGDEBUG, "PVRChannelGroups - %s - %d %s channel groups loaded",
              __FUNCTION__, size(), m_bRadio ? "radio" : "TV");

    return true;
}
开发者ID:,项目名称:,代码行数:30,代码来源:

示例3: lock

bool CPVRChannelGroups::DeleteGroup(const CPVRChannelGroup &group)
{
  // don't delete internal groups
  if (group.IsInternalGroup())
  {
    CLog::Log(LOGERROR, "PVR - %s - cannot delete internal group '%s'", __FUNCTION__, group.GroupName().c_str());
    return false;
  }

  // delete the group in this container
  CSingleLock lock(m_critSection);
  for (std::vector<CPVRChannelGroupPtr>::iterator it = m_groups.begin(); it != m_groups.end(); it++)
  {
    if ((*it)->GroupID() == group.GroupID())
    {
      // update the selected group in the gui if it's deleted
      CPVRChannelGroupPtr selectedGroup = GetSelectedGroup();
      if (selectedGroup && *selectedGroup == group)
        g_PVRManager.SetPlayingGroup(GetGroupAll());

      m_groups.erase(it);
      break;
    }
  }

  // delete the group from the database
  CPVRDatabase *database = GetPVRDatabase();
  return database ? database->Delete(group) : false;
}
开发者ID:RobertMe,项目名称:xbmc,代码行数:29,代码来源:PVRChannelGroups.cpp

示例4: GetPVRDatabase

bool CPVRChannelGroups::LoadUserDefinedChannelGroups(void)
{
  CPVRDatabase *database = GetPVRDatabase();
  if (!database)
    return false;

  bool bSyncWithBackends = g_guiSettings.GetBool("pvrmanager.syncchannelgroups");

  CSingleLock lock(m_critSection);

  // load the other groups from the database
  int iSize = m_groups.size();
  database->Get(*this);
  CLog::Log(LOGDEBUG, "PVR - %s - %d user defined %s channel groups fetched from the database", __FUNCTION__, (int) (m_groups.size() - iSize), m_bRadio ? "radio" : "TV");

  // load groups from the backends if the option is enabled
  iSize = m_groups.size();
  if (bSyncWithBackends)
  {
    GetGroupsFromClients();
    CLog::Log(LOGDEBUG, "PVR - %s - %d new user defined %s channel groups fetched from clients", __FUNCTION__, (int) (m_groups.size() - iSize), m_bRadio ? "radio" : "TV");
  }
  else
    CLog::Log(LOGDEBUG, "PVR - %s - 'synchannelgroups' is disabled; skipping groups from clients", __FUNCTION__);

  // load group members
  for (std::vector<CPVRChannelGroupPtr>::iterator it = m_groups.begin(); it != m_groups.end(); it++)
    (*it)->Load();

  // persist changes if we fetched groups from the backends
  return bSyncWithBackends ? PersistAll() : true;
}
开发者ID:RobertMe,项目名称:xbmc,代码行数:32,代码来源:PVRChannelGroups.cpp

示例5: GetPVRDatabase

bool CPVRChannelGroups::LoadUserDefinedChannelGroups(void)
{
  CPVRDatabase *database = GetPVRDatabase();
  if (!database)
    return false;

  CSingleLock lock(m_critSection);

  /* load the other groups from the database */
  int iSize = size();
  database->Get(*this);
  CLog::Log(LOGDEBUG, "PVRChannelGroups - %s - %d user defined %s channel groups fetched from the database",
      __FUNCTION__, (int) (size() - iSize), m_bRadio ? "radio" : "TV");

  iSize = size();
  GetGroupsFromClients();
  CLog::Log(LOGDEBUG, "PVRChannelGroups - %s - %d new user defined %s channel groups fetched from clients",
      __FUNCTION__, (int) (size() - iSize), m_bRadio ? "radio" : "TV");

  /* load group members */
  for (unsigned int iGroupPtr = 1; iGroupPtr < size(); iGroupPtr++)
    at(iGroupPtr)->Load();

  return PersistAll();
}
开发者ID:Kr0nZ,项目名称:xbmc,代码行数:25,代码来源:PVRChannelGroups.cpp

示例6: OpenPVRDatabase

int CPVRChannelGroupInternal::LoadFromDb(bool bCompress /* = false */)
{
  CPVRDatabase *database = OpenPVRDatabase();
  if (!database)
    return -1;

  int iChannelCount = size();

  if (database->Get(*this) > 0)
  {
    if (bCompress)
      database->Compress(true);
  }
  else
  {
    CLog::Log(LOGINFO, "PVRChannelGroupInternal - %s - no channels in the database",
        __FUNCTION__);
  }

  database->Close();

  SortByChannelNumber();

  return size() - iChannelCount;
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例7: at

void CPVREpgs::Clear(bool bClearDb /* = false */)
{
  /* remove all pointers to epg tables on timers */
  for (unsigned int iTimerPtr = 0; iTimerPtr < PVRTimers.size(); iTimerPtr++)
    PVRTimers[iTimerPtr].SetEpgInfoTag(NULL);

  /* clear all epg tables and remove pointers to epg tables on channels */
  for (unsigned int iEpgPtr = 0; iEpgPtr < size(); iEpgPtr++)
  {
    CPVREpg *epg = at(iEpgPtr);
    epg->Clear();

    CPVRChannel *channel = (CPVRChannel *) epg->Channel();
    if (channel)
      channel->m_EPG = NULL;
  }

  /* remove all EPG tables */
  clear();

  /* clear the database entries */
  if (bClearDb)
  {
    CPVRDatabase *database = g_PVRManager.GetTVDatabase();
    database->Open();
    database->EraseEpg();
    database->Close();
  }

  m_iLastEpgUpdate  = 0;
  m_bDatabaseLoaded = false;
}
开发者ID:margro,项目名称:xbmc-antiquated,代码行数:32,代码来源:PVREpgs.cpp

示例8: RemoveOldEntries

bool CPVREpgs::RemoveOldEntries()
{
  bool bReturn = false;
  CLog::Log(LOGINFO, "PVREpgs - %s - removing old EPG entries",
      __FUNCTION__);

  CPVRDatabase *database = g_PVRManager.GetTVDatabase();
  CDateTime now = CDateTime::GetCurrentDateTime();

  if (!database->Open())
  {
    CLog::Log(LOGERROR, "PVREpgs - %s - cannot open the database",
        __FUNCTION__);
    return bReturn;
  }

  /* call Cleanup() on all known EPG tables */
  for (unsigned int iEpgPtr = 0; iEpgPtr < size(); iEpgPtr++)
  {
    at(iEpgPtr)->Cleanup(now);
  }

  /* remove the old entries from the database */
  bReturn = database->EraseOldEpgEntries();

  if (bReturn)
    CDateTime::GetCurrentDateTime().GetAsTime(m_iLastEpgCleanup);

  return bReturn;
}
开发者ID:margro,项目名称:xbmc-antiquated,代码行数:30,代码来源:PVREpgs.cpp

示例9: lock

void CPVRClients::SaveCurrentChannelSettings(void)
{
  CPVRChannelPtr channel;
  {
    CSingleLock lock(m_critSection);
    if (!GetPlayingChannel(channel) || !m_bIsValidChannelSettings)
      return;
  }

  CPVRDatabase *database = GetPVRDatabase();
  if (!database)
    return;

  if (g_settings.m_currentVideoSettings != g_settings.m_defaultVideoSettings)
  {
    CLog::Log(LOGDEBUG, "PVR - %s - persisting custom channel settings for channel '%s'",
        __FUNCTION__, channel->ChannelName().c_str());
    database->PersistChannelSettings(*channel, g_settings.m_currentVideoSettings);
  }
  else
  {
    CLog::Log(LOGDEBUG, "PVR - %s - no custom channel settings for channel '%s'",
        __FUNCTION__, channel->ChannelName().c_str());
    database->DeleteChannelSettings(*channel);
  }
}
开发者ID:AdolphHuan,项目名称:xbmc,代码行数:26,代码来源:PVRClients.cpp

示例10: LoadFromDb

bool CPVREpgs::LoadFromDb(bool bShowProgress /* = false */)
{
  if (m_bDatabaseLoaded)
    return m_bDatabaseLoaded;

  CPVRDatabase *database = g_PVRManager.GetTVDatabase();

  /* show the progress bar */
  CGUIDialogPVRUpdateProgressBar *scanner = NULL;
  if (bShowProgress)
  {
    scanner = (CGUIDialogPVRUpdateProgressBar *)g_windowManager.GetWindow(WINDOW_DIALOG_EPG_SCAN);
    scanner->Show();
    scanner->SetHeader(g_localizeStrings.Get(19004));
  }

  /* open the database */
  database->Open();

  /* load all EPG tables */
  bool bLoaded = false;
  unsigned int iSize = size();
  for (unsigned int iEpgPtr = 0; iEpgPtr < iSize; iEpgPtr++)
  {
    CPVREpg *epg = at(iEpgPtr);
    CPVRChannel *channel = epg->Channel();

    if (epg->LoadFromDb())
    {
      if (channel)
        channel->UpdateEPGPointers();

      bLoaded = true;
    }

    if (bShowProgress)
    {
      /* update the progress bar */
      if (channel)
        scanner->SetTitle(channel->ChannelName());

      scanner->SetProgress(iEpgPtr, iSize);
      scanner->UpdateState();
    }
  }

  /* close the database */
  database->Close();

  if (bShowProgress)
    scanner->Close();

  m_bDatabaseLoaded = bLoaded;

  return bLoaded;
}
开发者ID:margro,项目名称:xbmc-antiquated,代码行数:56,代码来源:PVREpgs.cpp

示例11: bReturn

bool CPVRChannelGroupInternal::Persist(void)
{
  bool bReturn(true);
  CSingleLock lock(m_critSection);

  bool bHasNewChannels = HasNewChannels();
  bool bHasChangedChannels = HasChangedChannels();

  /* open the database */
  CPVRDatabase *database = OpenPVRDatabase();
  if (!database)
    return false;

  if (bHasNewChannels || bHasChangedChannels)
  CLog::Log(LOGDEBUG, "CPVRChannelGroupInternal - %s - persisting %d channels",
      __FUNCTION__, (int) size());

  if (bHasNewChannels)
  {
    CLog::Log(LOGDEBUG, "CPVRChannelGroupInternal - %s - group '%s' has new channels. writing changes directly",
        __FUNCTION__, GroupName().c_str());
    /* write directly to get channel ids */
    for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
    {
      CPVRChannel *channel = at(iChannelPtr).channel;
      if (!channel->Persist())
      {
        CLog::Log(LOGERROR, "CPVRChannelGroupInternal - %s - failed to persist channel '%s'",
            __FUNCTION__, channel->ChannelName().c_str());
        bReturn = false;
      }
    }

    lock.Leave();
  }
  else if (bHasChangedChannels)
  {
    /* queue queries */
    for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++)
      at(iChannelPtr).channel->Persist(true);

    lock.Leave();

    /* and commit them */
    bReturn = database->CommitInsertQueries();
    if (!bReturn)
      CLog::Log(LOGERROR, "CPVRChannelGroupInternal - %s - failed to persist channels", __FUNCTION__);
  }

  if (bReturn)
    bReturn = CPVRChannelGroup::Persist();
  database->Close();

  return bReturn;
}
开发者ID:SirTomselon,项目名称:xbmc,代码行数:55,代码来源:PVRChannelGroupInternal.cpp

示例12: GetPVRDatabase

bool CPVRChannelGroups::LoadUserDefinedChannelGroups(void)
{
  CPVRDatabase *database = GetPVRDatabase();
  if (!database)
    return false;

  bool bSyncWithBackends = CSettings::Get().GetBool("pvrmanager.syncchannelgroups");

  CSingleLock lock(m_critSection);

  // load the other groups from the database
  int iSize = m_groups.size();
  database->Get(*this);
  CLog::Log(LOGDEBUG, "PVR - %s - %d user defined %s channel groups fetched from the database", __FUNCTION__, (int) (m_groups.size() - iSize), m_bRadio ? "radio" : "TV");

  // load groups from the backends if the option is enabled
  iSize = m_groups.size();
  if (bSyncWithBackends)
  {
    GetGroupsFromClients();
    CLog::Log(LOGDEBUG, "PVR - %s - %d new user defined %s channel groups fetched from clients", __FUNCTION__, (int) (m_groups.size() - iSize), m_bRadio ? "radio" : "TV");
  }
  else
    CLog::Log(LOGDEBUG, "PVR - %s - 'synchannelgroups' is disabled; skipping groups from clients", __FUNCTION__);

  std::vector<CPVRChannelGroupPtr> emptyGroups;

  // load group members
  for (std::vector<CPVRChannelGroupPtr>::iterator it = m_groups.begin(); it != m_groups.end(); it++)
  {
    // load only user defined groups, as internal group is already loaded
    if (!(*it)->IsInternalGroup())
    {
      if (!(*it)->Load())
      {
        CLog::Log(LOGDEBUG, "PVR - %s - failed to load channel group '%s'", __FUNCTION__, (*it)->GroupName().c_str());
        return false;
      }

      // remove empty groups when sync with backend is enabled
      if (bSyncWithBackends && (*it)->Size() == 0)
        emptyGroups.push_back(*it);
    }
  }

  for (std::vector<CPVRChannelGroupPtr>::iterator it = emptyGroups.begin(); it != emptyGroups.end(); it++)
  {
    CLog::Log(LOGDEBUG, "PVR - %s - deleting empty group '%s'", __FUNCTION__, (*it)->GroupName().c_str());
    DeleteGroup(*(*it));
  }

  // persist changes if we fetched groups from the backends
  return bSyncWithBackends ? PersistAll() : true;
}
开发者ID:DJMatty,项目名称:xbmc,代码行数:54,代码来源:PVRChannelGroups.cpp

示例13: iClientId

int CPVRClients::RegisterClient(AddonPtr client, bool* newRegistration/*=NULL*/)
{
  int iClientId(-1);

  if (newRegistration)
    *newRegistration = false;

  if (!client->Enabled())
    return -1;

  CLog::Log(LOGDEBUG, "%s - registering add-on '%s'", __FUNCTION__, client->Name().c_str());

  CPVRDatabase *database = GetPVRDatabase();
  if (!database)
    return -1;

  // check whether we already know this client
  iClientId = database->GetClientId(client->ID());

  // try to register the new client in the db
  if (iClientId < 0)
  {
    if ((iClientId = database->Persist(client)) < 0)
    {
      CLog::Log(LOGERROR, "PVR - %s - can't add client '%s' to the database", __FUNCTION__, client->Name().c_str());
      return -1;
    }
    else if (newRegistration)
      *newRegistration = true;
  }

  PVR_CLIENT addon;
  // load and initialise the client libraries
  {
    CSingleLock lock(m_critSection);
    PVR_CLIENTMAP_CITR existingClient = m_clientMap.find(iClientId);
    if (existingClient != m_clientMap.end())
    {
      // return existing client
      addon = existingClient->second;
    }
    else
    {
      // create a new client instance
      addon = boost::dynamic_pointer_cast<CPVRClient>(client);
      m_clientMap.insert(std::make_pair(iClientId, addon));
    }
  }

  if (iClientId < 0)
    CLog::Log(LOGERROR, "PVR - %s - can't register add-on '%s'", __FUNCTION__, client->Name().c_str());

  return iClientId;
}
开发者ID:Sithisackt,项目名称:kodi,代码行数:54,代码来源:PVRClients.cpp

示例14: GetPVRDatabase

int CPVRChannelGroup::LoadFromDb(bool bCompress /* = false */)
{
  CPVRDatabase *database = GetPVRDatabase();
  if (!database)
    return -1;

  int iChannelCount = Size();

  database->Get(*this);

  return Size() - iChannelCount;
}
开发者ID:Cobrettini,项目名称:xbmc,代码行数:12,代码来源:PVRChannelGroup.cpp

示例15: LoadFromDb

int CPVRChannelGroup::LoadFromDb(bool bCompress /* = false */)
{
  CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase();
  if (!database || !database->Open())
    return -1;

  int iChannelCount = size();

  database->GetChannelsInGroup(this);
  database->Close();

  return size() - iChannelCount;
}
开发者ID:,项目名称:,代码行数:13,代码来源:


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