MeVisLab Toolbox Reference
mlDICOMCachedIOTreeCacheMap.h
Go to the documentation of this file.
1 // Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2 // **InsertLicense** code
3 //----------------------------------------------------------------------------------
6 
11 //----------------------------------------------------------------------------------
12 #pragma once
13 
14 #include "MLDICOMCachedIOSystem.h"
15 #include <mlTypeDefs.h>
16 
17 #include <ThirdPartyWarningsDisable.h>
18 #include <list>
19 #include <map>
20 #include <vector>
21 #include <ThirdPartyWarningsRestore.h>
22 
26 
27 // Forwards
30 namespace ML_NAMESPACE {
31  class IntField;
32  class DicomMessageCollector;
33 };
34 
38 {
39 public:
42 
45 
54  MLint flush(const MLint maxBytes, const bool flushAll=false);
55 
58 
61 
64 
67 
70 
72  void setMaxNumMegaBytes(MLint maxNumMegaBytes);
73 
76 
78  ML_NAMESPACE::IntField& getMaxNumMegaBytesFld();
79 
82 
84  void storeSingleFrameTree(DCMTree::TreePtr singleFrameTree,
85  const ML_NAMESPACE::DICOMCachedIOFileHandle &origFileHandle,
86  size_t frameIndex);
87 
90  DCMTree::TreePtr &treePtr);
91 
94  DCMTree::TreePtr &treePtr);
95 
98  DCMTree::TreePtr &treePtr,
99  ML_NAMESPACE::DicomMessageCollector &dcmMsgCollector);
100 
103  const ML_NAMESPACE::DICOMCachedIOFileHandle &fileHandle);
104 
108 
110  inline std::vector< MLDICOMCachedIODCMTreeLoaderPlugin *>& getTreeLoaderPlugins() { return _treeLoaderPlugins; }
111 
113  inline const std::vector< MLDICOMCachedIODCMTreeLoaderPlugin* >& getConstTreeLoaderPlugins() const { return _treeLoaderPlugins; }
114 
116  inline std::vector< MLDICOMCachedIODCMTreeWriterPlugin* >& getTreeWriterPlugins() { return _treeWriterPlugins; }
117 
119  inline const std::vector< MLDICOMCachedIODCMTreeWriterPlugin*>& getConstTreeWriterPlugins() const { return _treeWriterPlugins; }
120 
122  void clear();
123 
124 protected:
130  DCMTree::TreePtr &treePtr);
131 
132 
136 
142 
144  std::list<ML_NAMESPACE::DICOMCachedIOFileHandle> _recentlyCached;
145 
148 
151 
154 
156  std::vector< MLDICOMCachedIODCMTreeLoaderPlugin *> _treeLoaderPlugins;
157 
159  std::vector< MLDICOMCachedIODCMTreeWriterPlugin *> _treeWriterPlugins;
160 };
Project global and OS specific declarations.
#define MLDICOMCachedIO_EXPORT
If included by external modules, exported symbols are declared as import symbols.
Base class for plugins which support loading of DICOM trees (this class already implements basic file...
Base class for plugins which support writing of DICOM trees (this class already implements basic file...
Class describing one entry in the MLDICOMCachedIOTreeCache of cached DICOM trees.
Class containing the DCMTree look up map and the list of most recently used DICOM files as names.
std::map< ml::DICOMCachedIOFileHandle, MLDICOMCachedIOTreeCacheSingleMFMapEntry > _singleFrameCache
The map of SingleMultiFrame Frames extracted from multi-frame files.
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 maxByte...
MLint getMaxNumMegaBytes() const
Return maximum number of bytes used for tag data.
MLint getNumFlushedBytes() const
Returns the number of flushed bytes since most recent recent resetNumFlushedBytes().
const std::vector< MLDICOMCachedIODCMTreeLoaderPlugin * > & getConstTreeLoaderPlugins() const
Return constant vector of DICOM tree loader plugins.
const std::vector< MLDICOMCachedIODCMTreeWriterPlugin * > & getConstTreeWriterPlugins() const
Return constant vector of DICOM tree writer plugins.
std::vector< MLDICOMCachedIODCMTreeLoaderPlugin * > _treeLoaderPlugins
Vector of loader plugins.
MLint _totalNumBytes
Total number of bytes in all DICOM trees.
std::map< ml::DICOMCachedIOFileHandle, MLDICOMCachedIOTreeCacheMapEntry > _cache
The tree map.
void resetNumFlushedBytes()
Sets counter of flushed bytes to 0.
~MLDICOMCachedIOTreeCacheMap()
Destructor; clears and deletes the MLDICOMCachedIODCMTreeLoaderPlugins and MLDICOMCachedIODCMTreeWrit...
void flushSingleFrameCache()
Clears all cached singleFrameTrees, because they are normally excluded from normal flushing.
MLint getTotalNumberOfBytes() const
Return currently number of cached tree data in bytes.
MLint _numFlushedBytes
Counter for number of flushed bytes since most recent resetNumFlushedBytes().
MLErrorCode addDCMTree(const ml::DICOMCachedIOFileHandle &fileHandle, DCMTree::TreePtr &treePtr)
See DICOMCachedIOTreeCache::addDCMTree().
MLint flush()
Same as flush(getMaxNumBytes(), false).
MLDICOMCachedIOTreeCacheMap()
Constructor; it is initialized with 250 MB of cache for DICOM tree tag data.
MLErrorCode saveDCMTree(DCMTree::Const_TreePtr dcmTree, const ml::DICOMCachedIOFileHandle &fileHandle)
See DICOMCachedIOTreeCache::saveDCMTree().
MLErrorCode loadDCMTree(const ml::DICOMCachedIOFileHandle &fileHandle, DCMTree::TreePtr &treePtr, ml::DicomMessageCollector &dcmMsgCollector)
See DICOMCachedIOTreeCache::loadDCMTree().
void storeSingleFrameTree(DCMTree::TreePtr singleFrameTree, const ml::DICOMCachedIOFileHandle &origFileHandle, size_t frameIndex)
See DICOMCachedIOTreeCache::storeSingleFrameTree().
void clear()
Clears the DICOM trees cache singleton and resets all counters.
void removeAssociatedEntries(const ml::DICOMCachedIOFileHandle &fileHandle)
Removes cached multi-frame data and/or tree related to fileHandle.
MLErrorCode _addDCMTree(const ml::DICOMCachedIOFileHandle &fileHandle, DCMTree::TreePtr &treePtr)
Internal method that adds the given DICOM tree to the cache map with the specified fileHandle as key.
MLint getMaxNumBytes() const
Return maximum number of bytes used for tag data.
ml::IntField * _limitInMegaBytesFld
IntField specifying the maximum number of value mega bytes allowed in all DICOM trees.
ml::IntField & getMaxNumMegaBytesFld()
Returns field that specifies the maximum number of mega bytes for tag data.
std::list< ml::DICOMCachedIOFileHandle > _recentlyCached
Stores the file names of DCMTrees added to cache in the order of caching.
std::vector< MLDICOMCachedIODCMTreeLoaderPlugin * > & getTreeLoaderPlugins()
Return modifiable vector of DICOM tree loader plugins.
std::vector< MLDICOMCachedIODCMTreeWriterPlugin * > & getTreeWriterPlugins()
Return modifiable vector of DICOM tree writer plugins.
MLErrorCode getCachedDCMTree(const ml::DICOMCachedIOFileHandle &fileHandle, DCMTree::TreePtr &treePtr)
See DICOMCachedIOTreeCache::getCachedDCMTree().
void setMaxNumMegaBytes(MLint maxNumMegaBytes)
Set maximum number of mega bytes used for tag data. Values < 0 are clamped to 0.
std::vector< MLDICOMCachedIODCMTreeWriterPlugin * > _treeWriterPlugins
Vector of writer plugins.
Class describing one SingleMultiFrameFrame entry in the map of locked single frames in the MLDICOMCac...
Field to encapsulate an integer value.
Definition: mlFields.h:161
MLint32 MLErrorCode
Type of an ML Error code.
Definition: mlTypeDefs.h:818
Header of FileHandle class which should be used in DICOM importing modules to resolve the filename fo...
Header file of class describing one entry in the MLDICOMCachedIOTreeCache of cached DICOM trees.
Header file of class MLDICOMCachedIOTreeCacheSingleMFMapEntry which describes one SingleMultiFrameFra...
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition: mlTypeDefs.h:578
boost::shared_ptr< const Tree > Const_TreePtr
Definition: DCMTree_Lib.h:73
boost::shared_ptr< Tree > TreePtr
shared pointer to a DCMTree::Tree
Definition: DCMTree_Lib.h:70
DICOMCachedIOFileHandleBase< char > DICOMCachedIOFileHandle
"Forward" to DICOMCachedIOFileHandle.