#include "csdcm.h"

CSDCM::CSDCM()
{
    m_pListTag = new map<DcmTagKey, OFString>;
    m_pListChild = new map<DcmTagKey, CSDCM*>;

    m_DcmTagKey = DcmTagKey(0000, 0000);
}

CSDCM::CSDCM(DcmTagKey nKey)
{
    m_pListTag = new map<DcmTagKey, OFString>;
    m_pListChild = new map<DcmTagKey, CSDCM*>;

    m_DcmTagKey = nKey;
}

CSDCM::~CSDCM()
{
    m_pListTag->clear();
    delete m_pListTag;
    m_pListTag = NULL;

    if(m_pListChild!=NULL)
    {
        map<DcmTagKey, CSDCM*>::iterator it;
        for(it=m_pListChild->begin() ; it!=m_pListChild->end() ; ++it)
        {

            delete (it->second);
        }

    }
}

void CSDCM::InsertTagValue(DcmTagKey nKey, OFString& strData)
{
    map<DcmTagKey, OFString>::iterator it = m_pListTag->find(nKey);
    if(it->first!=nKey)
    {
        m_pListTag->insert({ nKey, strData });
    }
}

map<DcmTagKey, CSDCM*>* CSDCM::GetSequenceList()
{
    return m_pListChild;
}

CSDCM* CSDCM::InsertSequence(DcmTagKey nKey)
{
    CSDCM* pChild = new CSDCM(nKey);
    m_pListChild->insert({nKey, pChild});

    return pChild;
}
