MeVisLab Toolbox Reference
MLDICOMCachedIOTreeCache Class Reference

Class for DICOM tree accesses and caching of them for DICOM importing modules. More...

#include <mlDICOMCachedIOTreeCache.h>

Public Member Functions

 MLDICOMCachedIOTreeCache ()
 Constructor. Increments the reference counting and creates a cache if the count is 0. More...
 
 ~ MLDICOMCachedIOTreeCache ()
 Destructor. Decrements the reference counting and deletes the cache if the new count is 0. More...
 
MLint flush (const MLint maxBytes, const bool flushAll=false)
 Singleton and cache management. More...
 
MLint flush ()
 Same as flush(getMaxNumBytes(), false). More...
 
void flushSingleFrameCache ()
 Clears all cached singleFrameTrees, because they are normally excluded from normal flushing. More...
 
void setMaxNumBytes (MLint maxNumBytes)
 Set maximum number of bytes used for tree data. Values < 0 are clamped to 0. More...
 
void setMaxNumMegaBytes (MLint maxNumMegaBytes)
 Set maximum number of mega bytes used for tree data. Values < 0 are clamped to 0. More...
 
MLint getMaxNumBytes () const
 Return maximum number of bytes used for tree data. More...
 
MLint getMaxNumMegaBytes () const
 Return maximum number of bytes used for tree data. More...
 
MLint getTotalNumberOfBytes () const
 Returns the approximate number of cached bytes in trees. More...
 
ml::IntFieldgetMaxNumMegaBytesFld () const
 Return field that holds the maximum number of mega bytes used for tree data. More...
 
void clear ()
 Clears the DICOM trees cache map. 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 storeSingleFrameTree (DCMTree::TreePtr singleFrameTree, const ml::DICOMCachedIOFileHandle &origFileHandle, size_t frameIndex)
 Single frame management of multi-frame files. More...
 
MLErrorCode saveDCMTree (DCMTree::Const_TreePtr dcmTree, const ml::DICOMCachedIOFileHandle &fileHandle)
 DCMTree IO Support. More...
 
MLErrorCode getCachedDCMTree (const ml::DICOMCachedIOFileHandle &fileHandle, DCMTree::TreePtr &treePtr)
 Returns ML_RESULT_OK if the DICOM file given by fileName is already cached and then treePtr returns the related DCMTree, otherwise treePtr is reset to a nullptr pointer and an error code describing the cause is returned. More...
 
void removeAssociatedEntries (const ml::DICOMCachedIOFileHandle &fileHandle)
 Removed cached multi-frame data and/or tree related to fileHandle. More...
 
MLErrorCode loadDCMTree (const ml::DICOMCachedIOFileHandle &fileHandle, DCMTree::TreePtr &treePtr, ml::DicomMessageCollector &dcmMsgCollector)
 Loads the given non-constant DICOM tree specified by fileHandle into treePtr. More...
 
MLErrorCode loadConstantDCMTree (const ml::DICOMCachedIOFileHandle &fileHandle, DCMTree::Const_TreePtr &treePtr, ml::DicomMessageCollector &dcmMsgCollector)
 Loads the given constant DICOM tree specified by fileHandle into treePtr. More...
 
MLErrorCode loadSMFTree (const ml::DICOMCachedIOFileHandle &fileHandle, DCMTree::StructuredMFPtr &smfPtr, ml::DicomMessageCollector &dcmMsgCollector)
 Loads the given DICOM tree specified by fileName into smfPtr. More...
 
MLErrorCode addDCMTree (const ml::DICOMCachedIOFileHandle &fileHandle, DCMTree::TreePtr &treePtr)
 If no entry with the file handle exists, then it adds treePtr to the cache with the specified fileHandle as key; if the entry exists ML_OBJECT_OR_FILE_EXISTS is returned. More...
 

Static Public Member Functions

static MLDICOMCachedIOTreeCache singletonProxy ()
 Singleton and cache management. More...
 

Detailed Description

Class for DICOM tree accesses and caching of them for DICOM importing modules.

Definition at line 41 of file mlDICOMCachedIOTreeCache.h.

Constructor & Destructor Documentation

◆ MLDICOMCachedIOTreeCache()

MLDICOMCachedIOTreeCache::MLDICOMCachedIOTreeCache ( )

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

◆ ~ MLDICOMCachedIOTreeCache()

MLDICOMCachedIOTreeCache::~ MLDICOMCachedIOTreeCache ( )

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

Member Function Documentation

◆ addDCMTree()

MLErrorCode MLDICOMCachedIOTreeCache::addDCMTree ( const ml::DICOMCachedIOFileHandle fileHandle,
DCMTree::TreePtr treePtr 
)

If no entry with the file handle exists, then it adds treePtr to the cache with the specified fileHandle as key; if the entry exists ML_OBJECT_OR_FILE_EXISTS is returned.

Parameters
fileHandleKey by which the DICOM tree is added to the cache map.
treePtrThe DICOM tree that shall be stored in the cache map.
Returns
ML_RESULT_OK on success, otherwise a code describing the error.

◆ clear()

void MLDICOMCachedIOTreeCache::clear ( )

Clears the DICOM trees cache map.

◆ flush() [1/2]

MLint MLDICOMCachedIOTreeCache::flush ( )

Same as flush(getMaxNumBytes(), false).

◆ flush() [2/2]

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

Singleton and cache management.

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.

◆ flushSingleFrameCache()

void MLDICOMCachedIOTreeCache::flushSingleFrameCache ( )

Clears all cached singleFrameTrees, because they are normally excluded from normal flushing.

◆ getCachedDCMTree()

MLErrorCode MLDICOMCachedIOTreeCache::getCachedDCMTree ( const ml::DICOMCachedIOFileHandle fileHandle,
DCMTree::TreePtr treePtr 
)

Returns ML_RESULT_OK if the DICOM file given by fileName is already cached and then treePtr returns the related DCMTree, otherwise treePtr is reset to a nullptr pointer and an error code describing the cause is returned.

◆ getMaxNumBytes()

MLint MLDICOMCachedIOTreeCache::getMaxNumBytes ( ) const

Return maximum number of bytes used for tree data.

◆ getMaxNumMegaBytes()

MLint MLDICOMCachedIOTreeCache::getMaxNumMegaBytes ( ) const

Return maximum number of bytes used for tree data.

◆ getMaxNumMegaBytesFld()

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

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

◆ getNumFlushedBytes()

MLint MLDICOMCachedIOTreeCache::getNumFlushedBytes ( ) const

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

◆ getTotalNumberOfBytes()

MLint MLDICOMCachedIOTreeCache::getTotalNumberOfBytes ( ) const

Returns the approximate number of cached bytes in trees.

◆ loadConstantDCMTree()

MLErrorCode MLDICOMCachedIOTreeCache::loadConstantDCMTree ( const ml::DICOMCachedIOFileHandle fileHandle,
DCMTree::Const_TreePtr treePtr,
ml::DicomMessageCollector dcmMsgCollector 
)

Loads the given constant DICOM tree specified by fileHandle into treePtr.

Parameters
fileHandleFull path to DICOM tree file to be loaded.
treePtrThe loaded DICOM tree.
dcmMsgCollectorCollects error, info and issue messages (typically related to a handle).
Returns
ML_RESULT_OK on success, otherwise a code describing the error. If no MLDICOMCachedIODCMTreeLoaderPlugin is specified, ML_BAD_STATE is returned.

◆ loadDCMTree()

MLErrorCode MLDICOMCachedIOTreeCache::loadDCMTree ( const ml::DICOMCachedIOFileHandle fileHandle,
DCMTree::TreePtr treePtr,
ml::DicomMessageCollector dcmMsgCollector 
)

Loads the given non-constant DICOM tree specified by fileHandle into treePtr.

Parameters
fileHandleFull path to DICOM tree file to be loaded.
treePtrThe loaded DICOM tree.
dcmMsgCollectorCollects error, info and issue messages (typically related to a handle).
Returns
ML_RESULT_OK on success, otherwise a code describing the error. If no MLDICOMCachedIODCMTreeLoaderPlugin is specified, ML_BAD_STATE is returned.

◆ loadSMFTree()

MLErrorCode MLDICOMCachedIOTreeCache::loadSMFTree ( const ml::DICOMCachedIOFileHandle fileHandle,
DCMTree::StructuredMFPtr smfPtr,
ml::DicomMessageCollector dcmMsgCollector 
)

Loads the given DICOM tree specified by fileName into smfPtr.

Parameters
fileHandleFull path to SMF DICOM tree file to be loaded.
smfPtrThe structured MF used to wrap the loaded tree.
dcmMsgCollectorCollects error, info and issue messages (typically related to a handle).
Returns
ML_RESULT_OK on success, otherwise a code describing the error.

◆ removeAssociatedEntries()

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

Removed cached multi-frame data and/or tree related to fileHandle.

In case of a removed tree also the associated value size stored in the key is returned, otherwise in all cases 0 is returned.

◆ resetNumFlushedBytes()

void MLDICOMCachedIOTreeCache::resetNumFlushedBytes ( )

Sets counter of flushed bytes to 0.

◆ saveDCMTree()

MLErrorCode MLDICOMCachedIOTreeCache::saveDCMTree ( DCMTree::Const_TreePtr  dcmTree,
const ml::DICOMCachedIOFileHandle fileHandle 
)

DCMTree IO Support.

Saves the given DICOM tree in the file specified by fileHandle. Returns ML_RESULT_OK on success, otherwise a code describing the error.

◆ setMaxNumBytes()

void MLDICOMCachedIOTreeCache::setMaxNumBytes ( MLint  maxNumBytes)

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

◆ setMaxNumMegaBytes()

void MLDICOMCachedIOTreeCache::setMaxNumMegaBytes ( MLint  maxNumMegaBytes)

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

◆ singletonProxy()

static MLDICOMCachedIOTreeCache MLDICOMCachedIOTreeCache::singletonProxy ( )
static

Singleton and cache management.

Singleton returning the global DCMTree cache map. The instance will be created automatically if still not existent.

◆ storeSingleFrameTree()

void MLDICOMCachedIOTreeCache::storeSingleFrameTree ( DCMTree::TreePtr  singleFrameTree,
const ml::DICOMCachedIOFileHandle origFileHandle,
size_t  frameIndex 
)

Single frame management of multi-frame files.

Adds a new handle and tree to the cache of single frames. Note that single frame trees are excluded from flushing. They must be cleared explicitly cache with the flushSingleFrameCache() command.

Parameters
singleFrameTreeThe DCMTree build frame a specific single frame inside a multi-frame file.
origFileHandleThe original file handle (without "*" or "#" + frameIndex at its end).
frameIndexThe DCMTree build frame a specific single frame inside a multi-frame file.

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