1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
/*
*
* Copyright (C) 2002-2023, OFFIS e.V.
* All rights reserved. See COPYRIGHT file for details.
*
* This software and supporting documentation were developed by
*
* OFFIS e.V.
* R&D Division Health
* Escherweg 2
* D-26121 Oldenburg, Germany
*
*
* Module: dcmdata
*
* Author: Marco Eichelberg
*
* Purpose: class DcmPrivateTagCache
*
*/
#include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
#include "dcmtk/dcmdata/dcpcache.h"
#include "dcmtk/dcmdata/dcelem.h" /* for DcmElement, DcmObject */
DcmPrivateTagCacheEntry::DcmPrivateTagCacheEntry(const DcmTagKey& tk, const char *pc)
: tagKey(tk)
, privateCreator(pc)
{
}
DcmPrivateTagCacheEntry::~DcmPrivateTagCacheEntry()
{
}
const char *DcmPrivateTagCacheEntry::getPrivateCreator() const
{
return privateCreator.c_str();
}
OFBool DcmPrivateTagCacheEntry::isPrivateCreatorFor(const DcmTagKey& tk) const
{
return (tagKey.getGroup() == tk.getGroup()) &&
((tagKey.getElement() << 8) == (tk.getElement() & 0xff00));
}
/* ======================================================================= */
DcmPrivateTagCache::DcmPrivateTagCache()
: list_()
{
}
DcmPrivateTagCache::~DcmPrivateTagCache()
{
clear();
}
void DcmPrivateTagCache::clear()
{
OFListIterator(DcmPrivateTagCacheEntry *) first = list_.begin();
OFListIterator(DcmPrivateTagCacheEntry *) last = list_.end();
while (first != last)
{
delete (*first);
first = list_.erase(first);
}
}
const char *DcmPrivateTagCache::findPrivateCreator(const DcmTagKey& tk) const
{
OFListConstIterator(DcmPrivateTagCacheEntry *) first = list_.begin();
OFListConstIterator(DcmPrivateTagCacheEntry *) last = list_.end();
while (first != last)
{
if ((*first)->isPrivateCreatorFor(tk)) return (*first)->getPrivateCreator();
++first;
}
return NULL;
}
void DcmPrivateTagCache::updateCache(DcmObject *dobj)
{
if (dobj)
{
const DcmTag& tag = dobj->getTag();
if (dobj->isLeaf() && (tag.getGTag() & 1) && (tag.getETag() <= 0xff) && (tag.getETag() >= 0x10))
{
// dobj is DcmElement containing private creator
char *c = NULL;
if ((OFstatic_cast(DcmElement *, dobj)->getString(c)).good() && c)
{
list_.push_back(new DcmPrivateTagCacheEntry(tag, c));
}
}
}
}
|