1 /*=========================================================================
4 Module: $RCSfile: gdcmSeqEntry.cxx,v $
6 Date: $Date: 2004/06/22 14:57:11 $
7 Version: $Revision: 1.16 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.htm for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
19 #include "gdcmSeqEntry.h"
20 #include "gdcmSQItem.h"
22 #include "gdcmGlobal.h"
27 //-----------------------------------------------------------------------------
28 // Constructor / Destructor
30 * \ingroup gdcmSeqEntry
31 * \brief Constructor from a given gdcmSeqEntry
33 gdcmSeqEntry::gdcmSeqEntry(gdcmDictEntry* e, int depth)
36 delimitor_mode = false;
42 * \ingroup gdcmSeqEntry
43 * \brief Canonical destructor.
45 gdcmSeqEntry::~gdcmSeqEntry() {
46 for(ListSQItem::iterator cc = items.begin();cc != items.end();++cc)
49 std::cout << "delete SQItem" <<std:: endl;
55 //-----------------------------------------------------------------------------
58 * \brief canonical Printer
60 void gdcmSeqEntry::Print(std::ostream &os){
62 std::ostringstream s,s2;
64 // First, Print the Dicom Element itself.
70 if (GetReadLength() == 0)
73 // Then, Print each SQ Item
74 for(ListSQItem::iterator cc = items.begin();cc != items.end();++cc)
79 // at end, print the sequence terminator item, if any
81 for (int i=0;i<SQDepthLevel+1;i++)
84 if (seq_term != NULL) {
89 << " -------------- should have a sequence terminator item"
96 * \brief canonical Writer
98 void gdcmSeqEntry::Write(FILE *fp, FileType filetype) {
99 for(ListSQItem::iterator cc = GetSQItems().begin();
100 cc != GetSQItems().end();
102 std::cout << "Et un SQItem !" << std::endl;
103 (*cc)->Write(fp, filetype); // Don't remove param filetype !
106 //-----------------------------------------------------------------------------
109 /// \brief adds the passed ITEM to the ITEM chained List for this SeQuence.
110 void gdcmSeqEntry::AddEntry(gdcmSQItem *sqItem, int itemNumber) {
111 sqItem->SetSQItemNumber(itemNumber);
112 items.push_back(sqItem);
115 /// \brief Sets the depth level of a Sequence Entry embedded in a SeQuence
116 void gdcmSeqEntry::SetDepthLevel(int depth) {
117 SQDepthLevel = depth;
120 /// \brief return a pointer to the SQItem referenced by its ordinal number
121 /// (returns the first one if ordinal number is <0
122 /// returns the last one if ordinal number is > item number
124 gdcmSQItem *gdcmSeqEntry::GetSQItemByOrdinalNumber(int nb) {
126 return (*(items.begin()));
128 for(ListSQItem::iterator cc = items.begin();
134 return (*(items.end())); // Euhhhhh ?!? Is this the last one . FIXME
136 //-----------------------------------------------------------------------------
140 //-----------------------------------------------------------------------------
143 //-----------------------------------------------------------------------------