MeVisLab Toolbox Reference
MLDICOMCachedIOTagCache Class Reference

Class for cached DICOM tag loading from files for DICOM importing modules. More...

#include <mlDICOMCachedIOTagCache.h>

Public Member Functions

 MLDICOMCachedIOTagCache ()
 Constructor. Increments the reference counting and creates a cache if the count is 0. More...
 
 ~MLDICOMCachedIOTagCache ()
 Destructor. Decrements the reference counting and deletes the cache if the new count is 0. More...
 
DCMTree::Const_TagPtr getCachedDCMTag (const ml::DICOMCachedIOFileHandle &fileHandle, DCMTree::RawTagId rawTagId) const
 Tag access and prefetching: Returns a valid tag pointer if the fileName with the rawTagId is cached, otherwise a null tag is returned. More...
 
void removeAssociatedEntries (const ml::DICOMCachedIOFileHandle &fileHandle)
 Searches all tags and pixel data frames 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...
 
DCMTree::Const_TagPtr loadDCMTag (const ml::ConstantString &fileHandle, DCMTree::RawTagId rawTagId, MLint maxTagValueSizeToCache, bool *treeLoadFailed, bool *cacheMiss, ml::DicomMessageCollector &dcmMsgCollector)
 Looks for a tag with the id rawTagId in the cache and if it does not exist then it tries to load and add it into the cache. More...
 
void prefetchDCMTags (const ml::ConstantString &fileHandle, const std::set< MLuint32 > &tagIds, MLint maxTagValueSizeToCache, bool *treeLoadFailed, ml::DicomMessageCollector &dcmMsgCollector)
 Prefetch all tags of the tag types listed in tagIds and if their tag value sizes are smaller or equal maxTagValueSizeToCache. More...
 
void 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...
 
void flush ()
 Same as flush(getMaxNumBytes(), false). More...
 
MLint getNumFlushedBytes () const
 Returns the number of flushed bytes since most recent recent resetNumFlushedBytes(). More...
 
void resetNumFlushedBytes ()
 Sets counter of flushed bytes to 0. More...
 
void clear ()
 Clears the DICOM tag cache map. More...
 
void setMaxNumBytes (MLint maxNumBytes)
 Set maximum number of bytes (rounded down to MB limits) used for tag data; values < 0 are clamped to 0. More...
 
void setMaxNumMegaBytes (MLint maxNumMegaBytes)
 Set maximum number of mega bytes used for tag data; values < 0 are clamped to 0. More...
 
MLint getMaxNumBytes () const
 Return maximum number of bytes used for tag data (rounded down to MB limits). More...
 
MLint getMaxNumMegaBytes () const
 Return maximum number of mega bytes used for tag data. More...
 
ml::IntFieldgetMaxNumMegaBytesFld () const
 Return field that holds the maximum number of bytes used for tag data. More...
 
MLint getTotalNumberOfBytes () const
 Returns the approximate number of cached bytes. More...
 
const MLDICOMCachedIOTagCacheMapgetCachedIOTagCacheMap () const
 Returns a constant pointer to the cache map. More...
 

Static Public Member Functions

static MLDICOMCachedIOTagCache singletonProxy ()
 Singleton and cache management: Singleton returning the global DCMTree cache map. More...
 

Detailed Description

Class for cached DICOM tag loading from files for DICOM importing modules.

Definition at line 48 of file mlDICOMCachedIOTagCache.h.

Constructor & Destructor Documentation

◆ MLDICOMCachedIOTagCache()

MLDICOMCachedIOTagCache::MLDICOMCachedIOTagCache ( )

Constructor. Increments the reference counting and creates a cache if the count is 0.

◆ ~MLDICOMCachedIOTagCache()

MLDICOMCachedIOTagCache::~MLDICOMCachedIOTagCache ( )

Destructor. Decrements the reference counting and deletes the cache if the new count is 0.

Member Function Documentation

◆ clear()

void MLDICOMCachedIOTagCache::clear ( )

Clears the DICOM tag cache map.

◆ flush() [1/2]

void MLDICOMCachedIOTagCache::flush ( )

Same as flush(getMaxNumBytes(), false).

◆ flush() [2/2]

void MLDICOMCachedIOTagCache::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 MLDICOMCachedIOTagCache::getCachedDCMTag ( const ml::DICOMCachedIOFileHandle fileHandle,
DCMTree::RawTagId  rawTagId 
) const

Tag access and prefetching: Returns a valid tag pointer if the fileName with the rawTagId is cached, otherwise a null tag is returned.

No cache entry is created.

◆ getCachedIOTagCacheMap()

const MLDICOMCachedIOTagCacheMap* MLDICOMCachedIOTagCache::getCachedIOTagCacheMap ( ) const

Returns a constant pointer to the cache map.

◆ getMaxNumBytes()

MLint MLDICOMCachedIOTagCache::getMaxNumBytes ( ) const

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

◆ getMaxNumMegaBytes()

MLint MLDICOMCachedIOTagCache::getMaxNumMegaBytes ( ) const

Return maximum number of mega bytes used for tag data.

◆ getMaxNumMegaBytesFld()

ml::IntField& MLDICOMCachedIOTagCache::getMaxNumMegaBytesFld ( ) const

Return field that holds the maximum number of bytes used for tag data.

◆ getNumFlushedBytes()

MLint MLDICOMCachedIOTagCache::getNumFlushedBytes ( ) const

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

◆ getTotalNumberOfBytes()

MLint MLDICOMCachedIOTagCache::getTotalNumberOfBytes ( ) const

Returns the approximate number of cached bytes.

◆ loadDCMTag()

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

Looks for a tag with the id rawTagId in the cache and if it does not exist then it tries to load and add it into the cache.

In case of error or non existing tag a null tag pointer is returned. nullptr pointers are added by default as null tag to the cache if the tree exists, but the tags not to avoid that further requests to the tag will reload the trees to check whether the tag exists.

Parameters
fileHandleThe handle of the DICOM tree source (typically a file path) from where the DCMTree could be read if not found in the cache.
rawTagIdThe id of the tag to be read.
maxTagValueSizeToCacheSpecifies the maximum value size of a tag which shall be stored in the cache. Useful to avoid that huge binary tags are stored in cache, values < 0 mean that loaded tags shall not be cached.
treeLoadFailedIf treeLoadFailed is passed as non nullptr pointer then it will be set to true if a DICOM tree load failed, otherwise it is set to false.
cacheMissIf cacheMiss is passed as a non nullptr pointer then it will always be returned false except of the case that the tag was not found in the cache, but its loading is successful.
dcmMsgCollectorCollects error, info and issue messages (typically related to a handle).

◆ prefetchDCMTags()

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

Prefetch all tags of the tag types listed in tagIds and if their tag value sizes are smaller or equal maxTagValueSizeToCache.

If treeLoadFailed is passed as non nullptr pointer then it will be set to true if a DICOM tree load failed, otherwise it is set to false.

Parameters
fileHandleThe handle of the DICOM tree source (typically a file path) from where the DCMTree could be read if tags are not found in the cache.
tagIdsThe ids of the tags to be prefetched.
maxTagValueSizeToCacheSpecifies the maximum value size of a tag which shall be stored in the cache. Useful to avoid that huge binary tags are stored in cache, values < 0 mean that tags are not cached.
treeLoadFailedIf treeLoadFailed is passed as non nullptr pointer then it will be set to true if a DICOM tree load failed, otherwise it is set to false.
dcmMsgCollectorCollects error, info and issue messages (typically related to a handle).

◆ removeAssociatedEntries()

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

Searches all tags and pixel data frames 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.

◆ resetNumFlushedBytes()

void MLDICOMCachedIOTagCache::resetNumFlushedBytes ( )

Sets counter of flushed bytes to 0.

◆ setMaxNumBytes()

void MLDICOMCachedIOTagCache::setMaxNumBytes ( MLint  maxNumBytes)

Set maximum number of bytes (rounded down to MB limits) used for tag data; values < 0 are clamped to 0.

◆ setMaxNumMegaBytes()

void MLDICOMCachedIOTagCache::setMaxNumMegaBytes ( MLint  maxNumMegaBytes)

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

◆ singletonProxy()

static MLDICOMCachedIOTagCache MLDICOMCachedIOTagCache::singletonProxy ( )
static

Singleton and cache management: Singleton returning the global DCMTree cache map.

The instance will be created automatically if still not existent.


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