]> Creatis software - gdcm.git/blob - src/gdcmSeqEntry.cxx
Last commit before the final(?) one, for the new version.
[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    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
90 void gdcmSeqEntry::SetDepthLevel(int depth) {
91    SQDepthLevel = depth;
92 }
93 //-----------------------------------------------------------------------------
94 // Protected
95
96
97 //-----------------------------------------------------------------------------
98 // Private
99
100 // end-user intended : the guy *wants* to create his own SeQuence ?!?
101
102 gdcmDocEntry *gdcmSeqEntry::NewDocEntryByNumber(guint16 group,
103                                                 guint16 element) {
104 // TODO                           
105    gdcmDocEntry *a;   
106    return a;                              
107 }
108
109 gdcmDocEntry *gdcmSeqEntry::NewDocEntryByName  (std::string Name) {
110 // TODO :                         
111    gdcmDocEntry *a;   
112    return a;   
113 }
114
115 gdcmDocEntry *gdcmSeqEntry::GetDocEntryByNumber(guint16 group,
116                                                 guint16 element) {
117 // TODO                           
118    gdcmDocEntry *a;   
119    return a;                              
120 }       
121 //-----------------------------------------------------------------------------