]> Creatis software - gdcm.git/blob - src/gdcmSeqEntry.cxx
Still in a debugging status.
[gdcm.git] / src / gdcmSeqEntry.cxx
1 // gdcmSeqEntry.cxx
2 //-----------------------------------------------------------------------------
3 //
4 #include "gdcmSeqEntry.h"
5 #include "gdcmSQItem.h"
6 #include "gdcmTS.h"
7 #include "gdcmGlobal.h"
8 #include "gdcmUtil.h"
9
10 #include <iostream>
11 #include <iomanip>
12 //-----------------------------------------------------------------------------
13 // Constructor / Destructor
14 /**
15  * \ingroup gdcmSeqEntry
16  * \brief   Constructor from a given gdcmSeqEntry
17  */
18 gdcmSeqEntry::gdcmSeqEntry(gdcmDictEntry* e, int depth) 
19              : gdcmDocEntry(e)
20 {
21    delimitor_mode = false;
22    seq_term  = NULL;
23    SQDepthLevel = depth; // +1; // ??
24 }
25
26 /**
27  * \ingroup gdcmSeqEntry
28  * \brief   Canonical destructor.
29  */
30 gdcmSeqEntry::~gdcmSeqEntry() {
31    for(ListSQItem::iterator cc = items.begin();cc != items.end();++cc)
32    {
33       delete *cc;
34    }
35    if (!seq_term)
36       delete seq_term;
37 }
38
39 //-----------------------------------------------------------------------------
40 // Print
41 /*
42  * \ingroup gdcmSeqEntry
43  * \brief   canonical Printer
44  */
45 void gdcmSeqEntry::Print(std::ostream &os){
46
47    std::ostringstream s,s2;
48    std::string vr;
49    unsigned short int g, e;
50    long lgth;
51    size_t o;    
52    char greltag[10];  //group element tag
53    char st[20]; 
54
55    // First, Print the Dicom Element itself.
56    SetPrintLevel(2);   
57    PrintCommonPart(os);
58    s << std::endl;
59    os << s.str();   
60  
61     // Then, Print each SQ Item   
62      for(ListSQItem::iterator cc = items.begin();cc != items.end();++cc)
63    { 
64       //(*cc)->SetPrintLevel(GetPrintLevel()); aurait-ce un sens ?
65       (*cc)->Print(os);   
66    }
67    // at end, print the sequence terminator item, if any
68
69    if (delimitor_mode) {
70       s2 << "   | " ;   
71       os << s2.str();
72       if (seq_term != NULL) {
73          seq_term->Print(os);
74       }  
75       else 
76          std::cout << "      -------------- should have a sequence terminator item"
77                    << std::endl;      
78    }                    
79  }
80
81 //-----------------------------------------------------------------------------
82 // Public
83
84  /// \brief   adds the passed ITEM to the ITEM chained List for this SeQuence.      
85 void gdcmSeqEntry::AddEntry(gdcmSQItem *sqItem) {
86    items.push_back(sqItem);
87 }
88
89 /// \brief Sets the depth level of a Sequence Entry embedded in a SeQuence 
90 void gdcmSeqEntry::SetDepthLevel(int depth) {
91    SQDepthLevel = depth;
92 }
93
94 //-----------------------------------------------------------------------------
95 // Protected
96
97
98 //-----------------------------------------------------------------------------
99 // Private
100
101 // end-user intended : the guy *wants* to create his own SeQuence ?!?
102
103 /// \brief to be written, if really usefull
104 gdcmDocEntry *gdcmSeqEntry::NewDocEntryByNumber(guint16 group,
105                                                 guint16 element) {
106 // TODO
107    std::cout << "TODO : gdcmSeqEntry::NewDocEntryByNumber " << endl;                              
108    gdcmDocEntry *a;   
109    return a;                              
110 }
111
112 /// \brief to be written, if really usefull
113 gdcmDocEntry *gdcmSeqEntry::NewDocEntryByName  (std::string Name) {
114 // TODO :                         
115    std::cout << "TODO : gdcmSeqEntry::NewDocEntryByName " << endl;                                
116    gdcmDocEntry *a;   
117    return a;   
118 }
119
120 /// \brief to be written, if really usefull
121 gdcmDocEntry *gdcmSeqEntry::GetDocEntryByNumber(guint16 group,
122                                                 guint16 element) {
123 // TODO                           
124    std::cout << "TODO : gdcmSeqEntry::GetDocEntryByNumber " << endl;                              
125    gdcmDocEntry *a;   
126    return a;                              
127 }       
128 //-----------------------------------------------------------------------------