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
15#include <mlTypeDefs.h>
16#include <mlConstantString.h>
17
18#include <FMEThirdPartyWarningsDisable.h>
19#include <set>
20#include <FMEThirdPartyWarningsRestore.h>
21
22#include <DCMTree_Lib.h>
23#include "DCMTree_MFPixelTag.h"
24
25
26namespace DPL {
27 class Configuration;
28}
29
30ML_START_NAMESPACE
32 template<typename CT> class DICOMCachedIOFileHandleBase;
33
35
37 typedef DICOMCachedIOFileHandleBase<char> DICOMCachedIOFileHandle;
38 class DicomMessageCollector;
39 class IntField;
41ML_END_NAMESPACE
42
46
49
50 public:
59
64
68 DCMTree::Const_TagPtr getCachedDCMTag(const ML_NAMESPACE::DICOMCachedIOFileHandle &fileHandle,
69 DCMTree::RawTagId rawTagId) const;
70
75 void removeAssociatedEntries(const ML_NAMESPACE::DICOMCachedIOFileHandle &fileHandle);
76
95 DCMTree::Const_TagPtr loadDCMTag(const ML_NAMESPACE::ConstantString &fileHandle,
96 DCMTree::RawTagId rawTagId,
97 MLint maxTagValueSizeToCache,
98 bool *treeLoadFailed,
99 bool *cacheMiss,
100 ML_NAMESPACE::DicomMessageCollector &dcmMsgCollector);
101
115 void prefetchDCMTags(const ML_NAMESPACE::ConstantString &fileHandle,
116 const std::set<MLuint32> &tagIds,
117 MLint maxTagValueSizeToCache,
118 bool *treeLoadFailed,
119 ML_NAMESPACE::DicomMessageCollector &dcmMsgCollector);
120
129 void flush(const MLint maxBytes, const bool flushAll=false);
130
132 void flush();
133
136
139
141 void clear();
142
144 void setMaxNumBytes(MLint maxNumBytes);
145
147 void setMaxNumMegaBytes(MLint maxNumMegaBytes);
148
151
154
157
160
163
164private:
165
167 static MLDICOMCachedIOTagCacheMap *_tagCachePtr;
168
171 static MLuint _instanceCounter;
172
174 MLDICOMCachedIOTagCacheMap& _getCachedIOTagCacheMap() const;
175
176};
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.
ml::IntField & getMaxNumMegaBytesFld() const
Return field that holds the maximum number of bytes used for tag data.
const MLDICOMCachedIOTagCacheMap * getCachedIOTagCacheMap() const
Returns a constant pointer to the cache map.
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.
~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...
MLDICOMCachedIOTagCache(const MLDICOMCachedIOTagCache &)=delete
Delete copy constructor to prevent usage.
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.
MLDICOMCachedIOTagCache & operator=(const MLDICOMCachedIOTagCache &)=delete
Delete assignment operator to prevent usage.
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:117
MLuint64 MLuint
An unsigned ML integer type with at least 64 bits used for index calculations on very large images ev...
Definition mlTypeDefs.h:505
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition mlTypeDefs.h:489
boost::shared_ptr< const Tag > Const_TagPtr
Definition DCMTree_Lib.h:57
unsigned int RawTagId
Forward and includes of internally used DPL classes.