Exemplo n.º 1
0
void cSoundResourceManagerBase::Release()
{
    // Remove all resources
    // Note: if there are any valid resource proxies, they'll crash when their associated resource is dereferenced using cSoundBuffer::Get()  
    while(GetResourcesCount())
        RemoveResource(GetResourcesCount() - 1);
}
void CXTPCalendarResourcesManager::ApplyToCalendar(CXTPCalendarControl* pCalendar)
{
    CXTPCalendarResources arResources;

    int nRCCount = GetResourcesCount();
    for (int i = 0; i < nRCCount; i++)
    {
        CXTPCalendarResourceDescription* pRCdesc = GetResource(i);
        if (!pRCdesc || !pRCdesc->m_ptrResource)
        {
            ASSERT(FALSE);
            continue;
        }
        if (!pRCdesc->m_bEnabled || !pRCdesc->m_ptrResource->GetDataProvider())
        {
            continue;
        }

        arResources.Add(pRCdesc->m_ptrResource, TRUE);
    }

    if (arResources.GetCount())
    {
        pCalendar->SetResources(&arResources);
    }
}
Exemplo n.º 3
0
void cTextureManager::DeleteResource(unsigned int storage_index)
{
    if(storage_index < 0 || storage_index >= GetResourcesCount())
        return;

    vTextureResource *res = m_Resources[storage_index];
    RemoveResource(storage_index);
    ReleaseResource(res);
}
Exemplo n.º 4
0
void cTextureManager::RemoveResource(unsigned int storage_index)
{
    if(storage_index < 0 || storage_index >= GetResourcesCount())
        return;
    
    m_Resources[storage_index] = m_Resources.back();
    m_Resources[storage_index]->SetStorageIndex(storage_index);
    m_Resources.pop_back();
}
Exemplo n.º 5
0
int cTextureManager::FindResource(const std::string &id) const
{
    for(unsigned int i = 0; i < GetResourcesCount(); ++i)
    {
        if(m_Resources[i]->GetID() == id)
            return i;
    }

    return -1;
}
Exemplo n.º 6
0
int cSoundResourceManagerBase::FindResource(vResource<ALuint> *res) const
{
    if(!res)
        return -1;

    for(unsigned int i = 0; i < GetResourcesCount(); ++i)
    {
        if(m_Resources[i] == res)
            return i;
    }

    return -1;
}
Exemplo n.º 7
0
void cSoundResourceManagerBase::RemoveResource(unsigned int storage_index)
{
    if(storage_index >= GetResourcesCount())
        return;

    vResource<ALuint> *res = m_Resources[storage_index];

    m_Resources[storage_index] = m_Resources.back();
    // Update storage index
    m_Resources[storage_index]->SetStorageIndex(storage_index);
    m_Resources.pop_back();

    // Remove all traces of resource ever existing
    UnloadResource(res);

    if(res)
        delete res;
}
void CXTPCalendarResourcesManager::RemoveAll()
{
    int i, nDPCount = GetDataProvidersCount();

    for (i = 0; i < nDPCount; i++)
    {
        CXTPCalendarData* pData = GetDataProvider(i);
        _SaveCloseDPifNeed(pData);
    }

    //------------------------------------
    for (i = nDPCount - 1; i >= 0; i--)
    {
        RemoveDataProvider(i);
    }

    //------------------------------------
    int nRCCount = GetResourcesCount();
    for (i = nRCCount - 1; i >= 0; i--)
    {
        RemoveResource(i);
    }
}
Exemplo n.º 9
0
bool cSoundSourceManager::ReloadResource(unsigned int storage_index)
{
    if(storage_index >= GetResourcesCount())
        return false;

    vSoundSourceResource *rs = (vSoundSourceResource*)m_Resources[storage_index];
    if(!rs)
        return false;

    ALuint buffer = 0;
    // Reloading starts by releasing associated buffer
    UnloadResource(rs);
    // Recreate buffer and update resource state
    buffer = OpenAL::Get().CreateBuffer();
    if(alIsBuffer(buffer))
    {
        rs->SetState(EResourceState::Ok);
        rs->SetResource(buffer);
        return true;
    }

    return false;
}
void CXTPCalendarResourcesManager::_Load(CXTPPropExchange* pPX)
{
    if (!pPX || !pPX->IsLoading())
    {
        ASSERT(FALSE);
        return;

    }

    // Clear previous configuration.
    // Data providers will be saved and closed if this was specified.
    RemoveAll();

    pPX->ExchangeLocale();

    CXTPPropExchangeSection secDPs(pPX->GetSection(_T("DataProviders")));

    //int nDPCount = GetDataProvidersCount();
    CXTPPropExchangeEnumeratorPtr ptrEnumDPs(secDPs->GetEnumerator(_T("DataProvider")));
    POSITION posStorage = ptrEnumDPs->GetPosition();

    while (posStorage)
    {
        CString strConnStr;

        CXTPPropExchangeSection secDP(ptrEnumDPs->GetNext(posStorage));
        PX_String(&secDP, _T("ConnectionString"), strConnStr);

        if (!strConnStr.IsEmpty())
        {
            const int eDPFAll = xtpCalendarDPF_CreateIfNotExists |
                                xtpCalendarDPF_SaveOnDestroy |
                                xtpCalendarDPF_CloseOnDestroy;
            AddDataProvider(strConnStr, eDPFAll);
        }
    }

    //---------------------
    CXTPPropExchangeSection secResources(pPX->GetSection(_T("Resources")));

    CXTPPropExchangeEnumeratorPtr ptrEnumRCs(secResources->GetEnumerator(_T("Resource")));
    posStorage = ptrEnumRCs->GetPosition();

    while (posStorage)
    {
        CXTPPropExchangeSection secRC(ptrEnumRCs->GetNext(posStorage));
        CString strName;
        PX_String(&secRC, _T("Name"), strName);
        BOOL bAdded = AddResource(strName, FALSE);

        int nRCCount = GetResourcesCount();
        if (!bAdded || !nRCCount)
        {
            ASSERT(FALSE);
            continue;
        }

        CXTPCalendarResourceDescription* pRCdesc = GetResource(nRCCount - 1);
        if (!pRCdesc || !pRCdesc->m_ptrResource)
        {
            ASSERT(FALSE);
            continue;
        }

        PX_Bool(&secRC, _T("Enabled"), pRCdesc->m_bEnabled);
        PX_Bool(&secRC, _T("GenerateName"), pRCdesc->m_bGenerateName);


        //**********
        CString strConnStr;
        PX_String(&secRC, _T("ConnectionString"), strConnStr);
        CXTPCalendarData* pRCdp = GetDataProvider(strConnStr);
        pRCdesc->m_ptrResource->SetDataProvider(pRCdp);

        int nSchIdsCount = 0;
        PX_Int(&secRC, _T("SchedulesCount"), nSchIdsCount);

        if (nSchIdsCount)
        {
            CXTPPropExchangeEnumeratorPtr ptrEnumSchIDs(secRC->GetEnumerator(_T("Schedules")));
            POSITION posSchID = ptrEnumSchIDs->GetPosition();

            while (posSchID)
            {
                CXTPPropExchangeSection secSchID(ptrEnumSchIDs->GetNext(posSchID));
                ULONG ulSchID = 0;
                if (PX_ULong(&secSchID, _T("ScheduleID"), ulSchID))
                {
                    if (pRCdesc->m_ptrResource->GetSchedules())
                    {
                        pRCdesc->m_ptrResource->GetSchedules()->Add(ulSchID);
                    }
                }
            }
        }
    }
}
void CXTPCalendarResourcesManager::_Save(CXTPPropExchange* pPX)
{
    if (!pPX || !pPX->IsStoring())
    {
        ASSERT(FALSE);
        return;

    }
    pPX->ExchangeLocale();

    CXTPPropExchangeSection secDPs(pPX->GetSection(_T("DataProviders")));

    int nDPCount = GetDataProvidersCount();
    CXTPPropExchangeEnumeratorPtr ptrEnumDPs(secDPs->GetEnumerator(_T("DataProvider")));
    POSITION posStorage = ptrEnumDPs->GetPosition(nDPCount);

    for (int nDRNr = 0; nDRNr < nDPCount; nDRNr++)
    {
        CXTPCalendarData* pDP = GetDataProvider(nDRNr);
        ASSERT(pDP);
        if (!pDP)
        {
            continue;
        }

        CString strConnStr = pDP->GetConnectionString();

        CXTPPropExchangeSection secDP(ptrEnumDPs->GetNext(posStorage));
        PX_String(&secDP, _T("ConnectionString"), strConnStr);
    }

    //---------------------
    CXTPPropExchangeSection secResources(pPX->GetSection(_T("Resources")));

    int nRCCount = GetResourcesCount();
    CXTPPropExchangeEnumeratorPtr ptrEnumRCs(secResources->GetEnumerator(_T("Resource")));
    posStorage = ptrEnumRCs->GetPosition(nRCCount);

    for (int nRCNr = 0; nRCNr < nRCCount; nRCNr++)
    {
        CXTPCalendarResourceDescription* pRCdesc = GetResource(nRCNr);
        if (!pRCdesc || !pRCdesc->m_ptrResource)
        {
            ASSERT(FALSE);
            continue;
        }

        CXTPPropExchangeSection secRC(ptrEnumRCs->GetNext(posStorage));

        CString strRCName = pRCdesc->m_ptrResource->GetName();
        PX_String(&secRC, _T("Name"), strRCName);
        PX_Bool(&secRC, _T("Enabled"), pRCdesc->m_bEnabled);
        PX_Bool(&secRC, _T("GenerateName"), pRCdesc->m_bGenerateName);

        CXTPCalendarData* pRCdp = pRCdesc->m_ptrResource->GetDataProvider();
        if (pRCdp)
        {
            CString strConnStr = pRCdp->GetConnectionString();
            PX_String(&secRC, _T("ConnectionString"), strConnStr);

            int nSchIdsCount = 0;
            if (pRCdesc->m_ptrResource->GetSchedules())
            {
                nSchIdsCount = (int)pRCdesc->m_ptrResource->GetSchedules()->GetSize();
            }
            PX_Int(&secRC, _T("SchedulesCount"), nSchIdsCount);

            CXTPPropExchangeEnumeratorPtr ptrEnumSchIDs(secRC->GetEnumerator(_T("Schedules")));
            POSITION posSchID = ptrEnumSchIDs->GetPosition(nSchIdsCount);

            for (int k = 0; k < nSchIdsCount; k++)
            {
                CXTPPropExchangeSection secSchID(ptrEnumSchIDs->GetNext(posSchID));
                ULONG ulSchID = pRCdesc->m_ptrResource->GetSchedules()->GetAt(k);
                PX_ULong(&secSchID, _T("ScheduleID"), ulSchID);
            }
        }
    }
}