Example #1
0
PWIZ_API_DECL
void MSDataCache::update(const DataInfo& dataInfo,
                         const Spectrum& spectrum)
{
    if (!dataInfo.msd.run.spectrumListPtr.get() ||
        size()!=dataInfo.msd.run.spectrumListPtr->size())
        throw runtime_error("[MSDataCache::update()] Usage error."); 

    SpectrumInfo& info = at(spectrum.index);
    info.update(spectrum);

    // MRU binary data caching
    if (impl_->config.binaryDataCacheSize>0 && !info.data.empty())
    {
        // find and erase if we're already on the list
        Impl::MRU::iterator it = find(impl_->mru.begin(), impl_->mru.end(), &info);
        if (it!=impl_->mru.end()) 
            impl_->mru.erase(it);

        // put us at the front of the list
        impl_->mru.push_front(&info);

        // free binary data from the least recently used SpectrumInfo (back of list)
        if (impl_->mru.size() > impl_->config.binaryDataCacheSize)
        {
            SpectrumInfo* lru = impl_->mru.back();
            lru->clearBinaryData();
            impl_->mru.pop_back();
        }
    }
}
Example #2
0
void MSDataCache::Impl::updateMRU(SpectrumInfo* info)
{
    if (!info)
        throw runtime_error("[MSDataCache::updateMRU()] Null pointer.");

    // MRU binary data caching
    if (config.binaryDataCacheSize>0 && !info->data.empty())
    {
        // find and erase if we're already on the list
        MRU::iterator it = find(mru.begin(), mru.end(), info);
        if (it!=mru.end()) 
            mru.erase(it);

        // put us at the front of the list
        mru.push_front(info);

        // free binary data from the least recently used SpectrumInfo (back of list)
        if (mru.size() > config.binaryDataCacheSize)
        {
            SpectrumInfo* lru = mru.back();
            lru->clearBinaryData();
            mru.pop_back();
        }
    }
}