MeVisLab Toolbox Reference
mlDICOMCachedIOTagCache.h
Go to the documentation of this file.
1 // Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2 // **InsertLicense** code
3 //----------------------------------------------------------------------------------
5 
10 //----------------------------------------------------------------------------------
11 
12 #pragma once
13 
14 #include "MLDICOMCachedIOSystem.h"
15 #include <mlTypeDefs.h>
16 #include <mlConstantString.h>
17 
18 #include <ThirdPartyWarningsDisable.h>
19 #include <set>
20 #include <ThirdPartyWarningsRestore.h>
21 
22 #include <DCMTree_Lib.h>
23 #include "DCMTree_MFPixelTag.h"
24 
25 
26 namespace DPL {
27  class Configuration;
28 }
29 
30 ML_START_NAMESPACE
32  template<typename CT> class DICOMCachedIOFileHandleBase;
33 
35 
37  typedef DICOMCachedIOFileHandleBase<char> DICOMCachedIOFileHandle;
38  class DicomMessageCollector;
39  class IntField;
41 ML_END_NAMESPACE
42 
46 
49 
50  public:
55 
60 
65  DCMTree::RawTagId rawTagId) const;
66 
72 
91  DCMTree::Const_TagPtr loadDCMTag(const ML_NAMESPACE::ConstantString &fileHandle,
92  DCMTree::RawTagId rawTagId,
93  MLint maxTagValueSizeToCache,
94  bool *treeLoadFailed,
95  bool *cacheMiss,
96  ML_NAMESPACE::DicomMessageCollector &dcmMsgCollector);
97 
111  void prefetchDCMTags(const ML_NAMESPACE::ConstantString &fileHandle,
112  const std::set<MLuint32> &tagIds,
113  MLint maxTagValueSizeToCache,
114  bool *treeLoadFailed,
115  ML_NAMESPACE::DicomMessageCollector &dcmMsgCollector);
116 
125  void flush(const MLint maxBytes, const bool flushAll=false);
126 
128  void flush();
129 
132 
135 
137  void clear();
138 
140  void setMaxNumBytes(MLint maxNumBytes);
141 
143  void setMaxNumMegaBytes(MLint maxNumMegaBytes);
144 
147 
150 
153 
156 
159 
160 private:
161 
163  static MLDICOMCachedIOTagCacheMap *_tagCachePtr;
164 
167  static MLuint _instanceCounter;
168 
170  MLDICOMCachedIOTagCacheMap& _getCachedIOTagCacheMap() const;
171 
172 };
Project global and OS specific declarations.
#define MLDICOMCachedIO_EXPORT
If included by external modules, exported symbols are declared as import symbols.
Structure containing the DCMTag look up map and the list of most recently used DICOM files as names.
Class for cached DICOM tag loading from files for DICOM importing modules.
void resetNumFlushedBytes()
Sets counter of flushed bytes to 0.
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 ...
void clear()
Clears the DICOM tag cache map.
MLint getTotalNumberOfBytes() const
Returns the approximate number of cached bytes.
ml::IntField & getMaxNumMegaBytesFld() const
Return field that holds the maximum number of bytes used for tag data.
~MLDICOMCachedIOTagCache()
Destructor. Decrements the reference counting and deletes the cache if the new count is 0.
static MLDICOMCachedIOTagCache singletonProxy()
Singleton and cache management: Singleton returning the global DCMTree cache map.
void setMaxNumBytes(MLint maxNumBytes)
Set maximum number of bytes (rounded down to MB limits) used for tag data; values < 0 are clamped to ...
MLint getMaxNumBytes() const
Return maximum number of bytes used for tag data (rounded down to MB limits).
MLint getMaxNumMegaBytes() const
Return maximum number of mega bytes used for tag data.
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...
const MLDICOMCachedIOTagCacheMap * getCachedIOTagCacheMap() const
Returns a constant pointer to the cache map.
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,...
void flush()
Same as flush(getMaxNumBytes(), false).
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 maxByte...
MLint getNumFlushedBytes() const
Returns the number of flushed bytes since most recent recent resetNumFlushedBytes().
MLDICOMCachedIOTagCache()
Constructor. Increments the reference counting and creates a cache if the count is 0.
void setMaxNumMegaBytes(MLint maxNumMegaBytes)
Set maximum number of mega bytes used for tag data; values < 0 are clamped to 0.
void removeAssociatedEntries(const ml::DICOMCachedIOFileHandle &fileHandle)
Searches all tags and pixel data frames with the given fileHandle in the cache and removes them; note...
Small helper class to manage a list of data frames related to a filename.
Field to encapsulate an integer value.
Definition: mlFields.h:161
MLuint64 MLuint
An unsigned ML integer type with at least 64 bits used for index calculations on very large images ev...
Definition: mlTypeDefs.h:594
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 Tag > Const_TagPtr
Definition: DCMTree_Lib.h:63
unsigned int RawTagId
Definition: DCMTree_Lib.h:147
Forward and includes of internally used DPL classes.
DICOMCachedIOFileHandleBase< char > DICOMCachedIOFileHandle
"Forward" to DICOMCachedIOFileHandle.