Classes | Public Member Functions | Private Member Functions | Private Attributes
pwiz::analysis::MSDataCache Class Reference

simple memory cache for common MSData info More...

#include <MSDataCache.hpp>

Inheritance diagram for pwiz::analysis::MSDataCache:

List of all members.


struct  Config
 MSDataCache configuration. More...

Public Member Functions

 MSDataCache (const Config &config=Config())
const SpectrumInfospectrumInfo (size_t index, bool getBinaryData=false)
 access to SpectrumInfo with automatic update (open() must be called first)
MSDataAnalyzer interface
virtual void open (const DataInfo &dataInfo)
 start analysis of the data
virtual UpdateRequest updateRequested (const DataInfo &dataInfo, const SpectrumIdentity &spectrumIdentity) const
 ask analyzer if it wants an update
virtual void update (const DataInfo &dataInfo, const Spectrum &spectrum)
 analyze a single spectrum
- Public Member Functions inherited from pwiz::analysis::MSDataAnalyzer
virtual ~MSDataAnalyzer ()
virtual void close (const DataInfo &dataInfo)
 end analysis of the data

Private Member Functions

 MSDataCache (MSDataCache &)
MSDataCacheoperator= (MSDataCache &)

Private Attributes

boost::shared_ptr< Impl > impl_

Additional Inherited Members

- Public Attributes inherited from std::vector< T >
 STL member.

Detailed Description

simple memory cache for common MSData info

Memory caching is useful to minimize data retrieval expenses:

MSDataCache is a vector of SpectrumInfo objects, but also implements the MSDataAnalyzer interface. It can be used in two ways: 1) Updated from the outside via MSDataAnalyzer interface 2) Automatic updating via spectrumInfo() access method

Spectrum binary data (SpectrumInfo::data) is freed from the cache using a LRU (least recently used) algorithm. Binary data will be freed only to make room for a new update. The default cache size is 1, i.e. only the most recently updated binary data array is stored. Note that modifying the SpectrumInfo objects directly through the vector interface circumvents the LRU mechanism.

Usage #1: MSDataCache should be placed first in an MSDataAnalyzerContainer, so that it receives update() first. Other analyzers may then use it (preferably as const MSDataCache&) to access spectrum data when they receive update(). On updateRequested(), MSDataCache returns UpdateRequest_Ok to indicate that it should receive any updates that are requested by other analyzers. If no other analyzer requests an update, the cache will not be updated.

Usage #2: Instantiate independently and call open() to set reference to an MSData object. Calls to spectrumInfo() will return the requested SpectrumInfo, automatically updating the cache via call to SpectrumList::spectrum() if necessary.

Definition at line 74 of file MSDataCache.hpp.

Constructor & Destructor Documentation

pwiz::analysis::MSDataCache::MSDataCache ( const Config config = Config())
pwiz::analysis::MSDataCache::MSDataCache ( MSDataCache )

Member Function Documentation

virtual void pwiz::analysis::MSDataCache::open ( const DataInfo dataInfo)

start analysis of the data

Reimplemented from pwiz::analysis::MSDataAnalyzer.

Referenced by extractPeaks(), testAutomaticUpdate(), testDefault(), and testMRU().

virtual UpdateRequest pwiz::analysis::MSDataCache::updateRequested ( const DataInfo dataInfo,
const SpectrumIdentity spectrumIdentity 
) const

ask analyzer if it wants an update

Reimplemented from pwiz::analysis::MSDataAnalyzer.

Definition at line 93 of file MSDataCache.hpp.

References UpdateRequest_Ok.

// receive update() only if requested by another analyzer
virtual void pwiz::analysis::MSDataCache::update ( const DataInfo dataInfo,
const Spectrum spectrum 

analyze a single spectrum

Reimplemented from pwiz::analysis::MSDataAnalyzer.

Referenced by testDefault(), and testMRU().

const SpectrumInfo& pwiz::analysis::MSDataCache::spectrumInfo ( size_t  index,
bool  getBinaryData = false 

access to SpectrumInfo with automatic update (open() must be called first)

Referenced by extractPeaks(), and testAutomaticUpdate().

MSDataCache& pwiz::analysis::MSDataCache::operator= ( MSDataCache )

Member Data Documentation

boost::shared_ptr<Impl> pwiz::analysis::MSDataCache::impl_

Definition at line 108 of file MSDataCache.hpp.

The documentation for this class was generated from the following file: