]> Creatis software - gdcm.git/blob - src/gdcmObject.cxx
* FIX : bug fix in the gdcmDirList for the recursivity in directories
[gdcm.git] / src / gdcmObject.cxx
1 // gdcmObject.cxx
2 //-----------------------------------------------------------------------------
3 #include "gdcmObject.h"
4 #include "gdcmUtil.h"
5
6 //-----------------------------------------------------------------------------
7 // Constructor / Destructor
8 /**
9  * \ingroup gdcmObject
10  * \brief   
11  * @param   begin iterator of begin for the object
12  * @param   end   iterator of end for the object
13  */
14 gdcmObject::gdcmObject(ListTag::iterator begin,ListTag::iterator end) 
15 {
16    beginObj=begin;
17    endObj=end;
18
19    if(beginObj==endObj)
20       dbg.Verbose(0, "gdcmObject::gdcmObject empty list");
21 }
22
23 /**
24  * \ingroup gdcmObject
25  * \brief   Canonical destructor.
26  */
27 gdcmObject::~gdcmObject(void) 
28 {
29 }
30
31 //-----------------------------------------------------------------------------
32 // Print
33 /**
34  * \ingroup gdcmObject
35  * \brief   Prints the Object
36  * @return
37  */ 
38 void gdcmObject::Print(std::ostream &os)
39 {
40    if(printLevel>=0)
41    {
42       for(ListTag::iterator i=beginObj;i!=endObj;++i)
43       {
44          (*i)->SetPrintLevel(printLevel);
45          (*i)->Print(os);
46       }
47    }
48 }
49
50 //-----------------------------------------------------------------------------
51 // Public
52 /**
53  * \ingroup gdcmObject
54  * \brief   Get an entry by number
55  * @return
56  */ 
57 std::string gdcmObject::GetEntryByNumber(guint16 group, guint16 element) 
58 {
59    for(ListTag::iterator i=beginObj;i!=endObj;++i)
60    {
61       if ( (*i)->GetGroup()==group && (*i)->GetElement()==element)
62          return (*i)->GetValue();
63    }
64    
65    return GDCM_UNFOUND;
66 }
67
68 /**
69  * \ingroup gdcmObject
70  * \brief   Get an entry by name
71  * @param   name name of the searched element.
72  * @return
73  */ 
74 std::string gdcmObject::GetEntryByName(TagName name) 
75 {
76    gdcmDict *PubDict=gdcmGlobal::GetDicts()->GetDefaultPubDict();
77    gdcmDictEntry *dictEntry = (*PubDict).GetDictEntryByName(name); 
78
79    if( dictEntry == NULL)
80       return GDCM_UNFOUND;
81    return GetEntryByNumber(dictEntry->GetGroup(),dictEntry->GetElement()); 
82 }
83
84 /**
85  * \ingroup gdcmObject
86  * \brief   Get all entries in a hash table
87  * @return
88  */ 
89 TagHeaderEntryHT gdcmObject::GetEntry(void)
90 {
91    TagHeaderEntryHT HT;
92
93    for(ListTag::iterator it=beginObj;it!=endObj;++it)
94    {
95       HT.insert( PairHT( (*it)->GetKey(),(*it)) );
96    }
97
98    return(HT);
99 }
100
101 /**
102  * \ingroup gdcmObject
103  * \brief   Get all entries in a list
104  * @return
105  */ 
106 ListTag gdcmObject::GetListEntry(void)
107 {
108    ListTag list;
109
110    for(ListTag::iterator it=beginObj;it!=endObj;++it)
111    {
112       list.push_back(*it);
113    }
114
115    return(list);
116 }
117
118 //-----------------------------------------------------------------------------
119 // Protected
120
121 //-----------------------------------------------------------------------------
122 // Private
123
124 //-----------------------------------------------------------------------------