]> Creatis software - gdcm.git/blob - src/gdcmSeqEntry.cxx
general commit of (future) new classes.
[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) 
19              : gdcmDocEntry(e)
20 {
21    //ListSQItem items est un *champ* de gdcmSeqEntry.
22    // inutile de faire new ?
23       
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 }
36
37 //-----------------------------------------------------------------------------
38 // Print
39 /*
40  * \ingroup gdcmSeqEntry
41  * \brief   canonical Printer
42  */
43 void gdcmSeqEntry::Print(std::ostream &os){
44
45    std::ostringstream s;
46    string vr;
47    unsigned short int g, e;
48    long lgth;
49    size_t o;    
50    char greltag[10];  //group element tag
51    char st[20];
52       
53    // First, Print the Dicom Element itself. 
54    g  = GetGroup();
55    e  = GetElement();   
56    o  = GetOffset();
57    vr = GetVR();
58    sprintf(greltag,"%04x|%04x ",g,e);           
59    s << greltag ;
60    if (GetPrintLevel()>=2) { 
61       s << "lg : ";
62       lgth = GetReadLength(); // ReadLength, as opposed to UsableLength
63       if (lgth == 0xffffffff) {
64          sprintf(st,"x(ffff)");  // I said : "x(ffff)" !
65          s.setf(std::ios::left);
66          s << std::setw(10-strlen(st)) << " ";  
67          s << st << " ";
68          s.setf(std::ios::left);
69          s << std::setw(8) << "-1";      
70       } else {
71          sprintf(st,"x(%x)",lgth);
72          s.setf(std::ios::left);
73          s << std::setw(10-strlen(st)) << " ";  
74          s << st << " ";
75          s.setf(std::ios::left);
76          s << std::setw(8) << lgth; 
77       }
78       s << " Off.: ";
79       sprintf(st,"x(%x)",o); 
80       s << std::setw(10-strlen(st)) << " ";
81       s << st << " ";
82       s << std::setw(8) << o; 
83    }
84
85    s << "[" << vr  << "] ";
86    if (GetPrintLevel()>=1) {      
87       s.setf(std::ios::left);
88       s << std::setw(66-GetName().length()) << " ";
89    }
90     
91    s << "[" << GetName()<< "]";
92    s << std::endl;
93    os << s.str();
94  
95     // Then, Print each SQ Item   
96      for(ListSQItem::iterator cc = items.begin();cc != items.end();++cc)
97    {
98       //(*cc)->SetPrintLevel(GetPrintLevel()); aurait-ce un sens ?
99       (*cc)->Print(os);
100    }       
101              
102  }
103
104 //-----------------------------------------------------------------------------
105 // Public
106
107  /// \brief   adds the passed ITEM to the ITEM chained List for this SeQuence.      
108 void gdcmSeqEntry::AddEntry(gdcmSQItem *sqItem) {
109    items.push_back(sqItem);
110 }
111 //-----------------------------------------------------------------------------
112 // Protected
113
114 //-----------------------------------------------------------------------------
115 // Private
116
117 // end-user intended : the guy *wants* to create his own SeQuence ?!?
118 gdcmDocEntry *gdcmSeqEntry::NewDocEntryByNumber(guint16 group,
119                                                 guint16 element) {
120 // TODO                           
121    gdcmDocEntry *a;   
122    return a;                              
123 }
124
125 gdcmDocEntry *gdcmSeqEntry::NewDocEntryByName  (std::string Name) {
126 // TODO :                         
127    gdcmDocEntry *a;   
128    return a;
129 }       
130 //-----------------------------------------------------------------------------