MeVisLab Toolbox Reference
MLDICOMCachedIOTagCacheMap Class Reference

Structure containing the DCMTag look up map and the list of most recently used DICOM files as names. More...

#include <mlDICOMCachedIOTagCacheMap.h>

Classes

struct  TagHashFunction
 This is a self defined hash function for the boost::unordered map used as cache for tags. More...
 
struct  TagKey
 TagKey for the tag cache. More...
 

Public Types

typedef boost::unordered_map< TagKey, DCMTree::Const_TagPtr, TagHashFunctionCacheMapType
 Defines the map type to be used for tag caching. More...
 

Public Member Functions

 MLDICOMCachedIOTagCacheMap ()
 Constructor; it is initialized with 25 MB of cache for DICOM tree tag data. More...
 
 ~MLDICOMCachedIOTagCacheMap ()
 Destructor, cleaning up internal objects. More...
 
MLint getMaxNumBytes () const
 Return maximum number of bytes used for tag data (rounded down to MB limits). More...
 
void setMaxNumMegaBytes (MLint maxNumMegaBytes)
 Set maximum number of mega bytes used for tag data. Values < 0 are clamped to 0. More...
 
MLint getMaxNumMegaBytes () const
 Return maximum number of bytes used for tag data. More...
 
ml::IntFieldgetMaxNumMegaBytesFld ()
 Returns field that specifies the maximum number of bytes for tag data. More...
 
MLint getTotalNumberOfBytes () const
 Returns the approximate number of cached bytes. More...
 
MLint flush (const MLint maxBytes, const bool flushAll=false)
 Flushes entries which have no other references than those ones from the cache until the given maxBytes is undergone; values < 0 for maxBytes means unlimited cache size, which means that the call is ignored; returns the number of flushed bytes; if flushAll is true and flushing unreferenced entries did not undergo maxBytes then an additional loop is performed to flush entries which have references from outside the cache if not enough can be flushed to reach maxBytes - doing this, however, may lead to duplicate entries in memory after reloading them. More...
 
MLint flush ()
 Same as flush(getMaxNumBytes(), false). More...
 
MLint getNumFlushedBytes () const
 Returns the number of flushed bytes since most recent resetNumFlushedBytes(). More...
 
void resetNumFlushedBytes ()
 Sets counter of flushed bytes to 0. More...
 
void removeAssociatedEntries (const ml::DICOMCachedIOFileHandle &fileHandle)
 Searches all tags with the given fileHandle in the cache and removes them; note that this function has complexity O(n) since it has to check all cache entries. More...
 
void clear ()
 Clears the MLDICOMCachedIOTagCacheMap, and resets all counters. More...
 
DCMTree::Const_TagPtr getCachedDCMTag (const ml::DICOMCachedIOFileHandle &fileHandle, DCMTree::RawTagId rawTagId) const
 Returns a valid tag pointer if the fileName with the rawTagId is cached, otherwise a null tag is returned. More...
 
void insertTag (MLDICOMCachedIOTagCacheMap::TagKey &key, DCMTree::Const_TagPtr tagPtr, const MLint tagValSize)
 Helper to insert a tag and to update all related structures. More...
 
DCMTree::Const_TagPtr loadDCMTag (const ml::ConstantString &fileHandle, DCMTree::RawTagId rawTagId, MLint maxTagValueSizeToCache, bool *treeLoadFailed, bool *cacheMiss, ml::DicomMessageCollector &dcmMsgCollector)
 See DICOMCachedIOTagCache::loadDCMTag() for details. More...
 
void prefetchDCMTags (const ml::ConstantString &fileHandle, const std::set< MLuint32 > &tagIds, MLint maxTagValueSizeToCache, bool *treeLoadFailed, ml::DicomMessageCollector &dcmMsgCollector)
 See DICOMCachedIOTagCache::prefetchDCMTags() for details. More...
 

Protected Attributes

CacheMapType _cache
 The tag map for caching. More...
 
std::list< TagKey_recentlyCached
 Stores the file names of DCMTags added to cache in the order of caching. More...
 
MLint _totalNumBytes
 Total number of value bytes in all DICOM tags. More...
 
MLint _numFlushedBytes
 Counter for number of flushed bytes since most recent resetNumFlushedBytes(). More...
 
ml::IntField_limitInMegaBytesFld
 IntField specifying the maximum number of value bytes allowed in all DICOM tags. More...
 

Friends

class MLDICOMCachedIOTagCache
 Allow direct access from MLDICOMCachedIOTagCache. More...
 

Detailed Description

Structure containing the DCMTag look up map and the list of most recently used DICOM files as names.

Definition at line 40 of file mlDICOMCachedIOTagCacheMap.h.

Member Typedef Documentation

◆ CacheMapType

Defines the map type to be used for tag caching.

Definition at line 145 of file mlDICOMCachedIOTagCacheMap.h.

Constructor & Destructor Documentation

◆ MLDICOMCachedIOTagCacheMap()

MLDICOMCachedIOTagCacheMap::MLDICOMCachedIOTagCacheMap ( )

Constructor; it is initialized with 25 MB of cache for DICOM tree tag data.

◆ ~MLDICOMCachedIOTagCacheMap()

MLDICOMCachedIOTagCacheMap::~MLDICOMCachedIOTagCacheMap ( )

Destructor, cleaning up internal objects.

Member Function Documentation

◆ clear()

void MLDICOMCachedIOTagCacheMap::clear ( )

Clears the MLDICOMCachedIOTagCacheMap, and resets all counters.

◆ flush() [1/2]

MLint MLDICOMCachedIOTagCacheMap::flush ( )

Same as flush(getMaxNumBytes(), false).

◆ flush() [2/2]

MLint MLDICOMCachedIOTagCacheMap::flush ( const MLint  maxBytes,
const bool  flushAll = false 
)

Flushes entries which have no other references than those ones from the cache until the given maxBytes is undergone; values < 0 for maxBytes means unlimited cache size, which means that the call is ignored; returns the number of flushed bytes; if flushAll is true and flushing unreferenced entries did not undergo maxBytes then an additional loop is performed to flush entries which have references from outside the cache if not enough can be flushed to reach maxBytes - doing this, however, may lead to duplicate entries in memory after reloading them.

Currently the cache is organized as a FIFO list where oldest trees are flushed first.

◆ getCachedDCMTag()

DCMTree::Const_TagPtr MLDICOMCachedIOTagCacheMap::getCachedDCMTag ( const ml::DICOMCachedIOFileHandle fileHandle,
DCMTree::RawTagId  rawTagId 
) const

Returns a valid tag pointer if the fileName with the rawTagId is cached, otherwise a null tag is returned.

No cache entry is created.

◆ getMaxNumBytes()

MLint MLDICOMCachedIOTagCacheMap::getMaxNumBytes ( ) const

Return maximum number of bytes used for tag data (rounded down to MB limits).

◆ getMaxNumMegaBytes()

MLint MLDICOMCachedIOTagCacheMap::getMaxNumMegaBytes ( ) const

Return maximum number of bytes used for tag data.

◆ getMaxNumMegaBytesFld()

ml::IntField& MLDICOMCachedIOTagCacheMap::getMaxNumMegaBytesFld ( )

Returns field that specifies the maximum number of bytes for tag data.

◆ getNumFlushedBytes()

MLint MLDICOMCachedIOTagCacheMap::getNumFlushedBytes ( ) const

Returns the number of flushed bytes since most recent resetNumFlushedBytes().

◆ getTotalNumberOfBytes()

MLint MLDICOMCachedIOTagCacheMap::getTotalNumberOfBytes ( ) const

Returns the approximate number of cached bytes.

◆ insertTag()

void MLDICOMCachedIOTagCacheMap::insertTag ( MLDICOMCachedIOTagCacheMap::TagKey key,
DCMTree::Const_TagPtr  tagPtr,
const MLint  tagValSize 
)

Helper to insert a tag and to update all related structures.

◆ loadDCMTag()

DCMTree::Const_TagPtr MLDICOMCachedIOTagCacheMap::loadDCMTag ( const ml::ConstantString fileHandle,
DCMTree::RawTagId  rawTagId,
MLint  maxTagValueSizeToCache,
bool *  treeLoadFailed,
bool *  cacheMiss,
ml::DicomMessageCollector dcmMsgCollector 
)

See DICOMCachedIOTagCache::loadDCMTag() for details.

◆ prefetchDCMTags()

void MLDICOMCachedIOTagCacheMap::prefetchDCMTags ( const ml::ConstantString fileHandle,
const std::set< MLuint32 > &  tagIds,
MLint  maxTagValueSizeToCache,
bool *  treeLoadFailed,
ml::DicomMessageCollector dcmMsgCollector 
)

See DICOMCachedIOTagCache::prefetchDCMTags() for details.

◆ removeAssociatedEntries()

void MLDICOMCachedIOTagCacheMap::removeAssociatedEntries ( const ml::DICOMCachedIOFileHandle fileHandle)

Searches all tags with the given fileHandle in the cache and removes them; note that this function has complexity O(n) since it has to check all cache entries.

If the incoming handle is not an enhanced handle then also tags are cleared which have multi-frame handles built from fileHandle.
Removed tags update getTotalNumberOfBytes(), but not getNumFlushedBytes();.

◆ resetNumFlushedBytes()

void MLDICOMCachedIOTagCacheMap::resetNumFlushedBytes ( )

Sets counter of flushed bytes to 0.

◆ setMaxNumMegaBytes()

void MLDICOMCachedIOTagCacheMap::setMaxNumMegaBytes ( MLint  maxNumMegaBytes)

Set maximum number of mega bytes used for tag data. Values < 0 are clamped to 0.

Friends And Related Function Documentation

◆ MLDICOMCachedIOTagCache

friend class MLDICOMCachedIOTagCache
friend

Allow direct access from MLDICOMCachedIOTagCache.

Definition at line 175 of file mlDICOMCachedIOTagCacheMap.h.

Member Data Documentation

◆ _cache

CacheMapType MLDICOMCachedIOTagCacheMap::_cache
protected

The tag map for caching.

Definition at line 178 of file mlDICOMCachedIOTagCacheMap.h.

◆ _limitInMegaBytesFld

ml::IntField* MLDICOMCachedIOTagCacheMap::_limitInMegaBytesFld
protected

IntField specifying the maximum number of value bytes allowed in all DICOM tags.

Definition at line 191 of file mlDICOMCachedIOTagCacheMap.h.

◆ _numFlushedBytes

MLint MLDICOMCachedIOTagCacheMap::_numFlushedBytes
protected

Counter for number of flushed bytes since most recent resetNumFlushedBytes().

Definition at line 187 of file mlDICOMCachedIOTagCacheMap.h.

◆ _recentlyCached

std::list<TagKey> MLDICOMCachedIOTagCacheMap::_recentlyCached
protected

Stores the file names of DCMTags added to cache in the order of caching.

Definition at line 181 of file mlDICOMCachedIOTagCacheMap.h.

◆ _totalNumBytes

MLint MLDICOMCachedIOTagCacheMap::_totalNumBytes
protected

Total number of value bytes in all DICOM tags.

Definition at line 184 of file mlDICOMCachedIOTagCacheMap.h.


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