16 #include <FMEThirdPartyWarningsDisable.h>
19 #include <FMEThirdPartyWarningsRestore.h>
27 #include <FMEThirdPartyWarningsDisable.h>
28 #include <boost/unordered_map.hpp>
29 #include <FMEThirdPartyWarningsRestore.h>
31 namespace ML_NAMESPACE {
33 class DicomMessageCollector;
105 inline TagKey(
MLuint32 id,
const ML_NAMESPACE::ConstantString& fileName): _id(id), _fileName(fileName){}
109 return (_id == other.
_id) && (_fileName == other.
_fileName);
138 boost::hash_combine(hash, key.
_id);
145 typedef boost::unordered_map< TagKey, DCMTree::Const_TagPtr, TagHashFunction >
CacheMapType;
155 const MLint tagValSize);
160 MLint maxTagValueSizeToCache,
161 bool *treeLoadFailed,
163 ML_NAMESPACE::DicomMessageCollector &dcmMsgCollector);
167 const std::set<MLuint32> &tagIds,
168 MLint maxTagValueSizeToCache,
169 bool *treeLoadFailed,
170 ML_NAMESPACE::DicomMessageCollector &dcmMsgCollector);
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.
std::list< TagKey > _recentlyCached
Stores the file names of DCMTags added to cache in the order of caching.
boost::unordered_map< TagKey, DCMTree::Const_TagPtr, TagHashFunction > CacheMapType
Defines the map type to be used for tag caching.
MLint getTotalNumberOfBytes() const
Returns the approximate number of cached bytes.
MLint _numFlushedBytes
Counter for number of flushed bytes since most recent resetNumFlushedBytes().
DCMTree::Const_TagPtr getCachedDCMTag(const ml::DICOMCachedIOFileHandle &fileHandle, DCMTree::RawTagId rawTagId) const
Returns a valid tag pointer if the fileName with the rawTagId is cached, otherwise a null tag is retu...
MLint _totalNumBytes
Total number of value bytes in all DICOM tags.
void removeAssociatedEntries(const ml::DICOMCachedIOFileHandle &fileHandle)
Searches all tags with the given fileHandle in the cache and removes them; note that this function ha...
MLint flush()
Same as flush(getMaxNumBytes(), false).
void resetNumFlushedBytes()
Sets counter of flushed bytes to 0.
MLint getNumFlushedBytes() const
Returns the number of flushed bytes since most recent resetNumFlushedBytes().
ml::IntField & getMaxNumMegaBytesFld()
Returns field that specifies the maximum number of bytes for tag data.
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.
void insertTag(MLDICOMCachedIOTagCacheMap::TagKey &key, DCMTree::Const_TagPtr tagPtr, const MLint tagValSize)
Helper to insert a tag and to update all related structures.
void setMaxNumMegaBytes(MLint maxNumMegaBytes)
Set maximum number of mega bytes used for tag data. Values < 0 are clamped to 0.
MLint getMaxNumBytes() const
Return maximum number of bytes used for tag data (rounded down to MB limits).
CacheMapType _cache
The tag map for caching.
~MLDICOMCachedIOTagCacheMap()
Destructor, cleaning up internal objects.
ml::IntField * _limitInMegaBytesFld
IntField specifying the maximum number of value bytes allowed in all DICOM tags.
DCMTree::Const_TagPtr loadDCMTag(const ml::ConstantString &fileHandle, DCMTree::RawTagId rawTagId, MLint maxTagValueSizeToCache, bool *treeLoadFailed, bool *cacheMiss, ml::DicomMessageCollector &dcmMsgCollector)
See DICOMCachedIOTagCache::loadDCMTag() for details.
void prefetchDCMTags(const ml::ConstantString &fileHandle, const std::set< MLuint32 > &tagIds, MLint maxTagValueSizeToCache, bool *treeLoadFailed, ml::DicomMessageCollector &dcmMsgCollector)
See DICOMCachedIOTagCache::prefetchDCMTags() for details.
void clear()
Clears the MLDICOMCachedIOTagCacheMap, and resets all counters.
MLDICOMCachedIOTagCacheMap()
Constructor; it is initialized with 25 MB of cache for DICOM tree tag data.
Class for cached DICOM tag loading from files for DICOM importing modules.
Field to encapsulate an integer value.
size_t hash_value(MLGlobalFunctionKey const &key)
Calculates the hash key from last string segment.
Header of FileHandle class which should be used in DICOM importing modules to resolve the filename fo...
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
boost::shared_ptr< const Tag > Const_TagPtr
DICOMCachedIOFileHandleBase< char > DICOMCachedIOFileHandle
"Forward" to DICOMCachedIOFileHandle.
This is a self defined hash function for the boost::unordered map used as cache for tags.
size_t operator()(TagKey const &key) const
Calculates the has key from last string segment.
TagKey for the tag cache.
bool operator==(const TagKey &other) const
Returns true if _id and _fileName of *this and other are identical, otherwise false.
std::list< TagKey >::iterator _recentlyCachedIt
Iterator to the entry in _recentlyCached list for faster deletion there.
MLuint32 _id
The raw id of the tag.
TagKey()
Initializes _id to 0 and _fileHandle empty.
TagKey(MLuint32 id, const ml::ConstantString &fileName)
Initializes _id with id and _fileHandle with fileName.
ml::ConstantString _fileName
The handle of the DCMTree source associated to the tag.