1 /*=========================================================================
4 Module: $RCSfile: gdcmSeqEntry.cxx,v $
6 Date: $Date: 2004/06/23 15:01:57 $
7 Version: $Revision: 1.19 $
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 * \brief Canonical destructor.
44 gdcmSeqEntry::~gdcmSeqEntry() {
45 for(ListSQItem::iterator cc = items.begin();cc != items.end();++cc)
48 std::cout << "delete SQItem" <<std:: endl;
55 * \brief canonical Printer
57 void gdcmSeqEntry::Print(std::ostream &os){
59 // First, Print the Dicom Element itself.
61 gdcmDocEntry::Print(os);
64 if (GetReadLength() == 0)
67 // Then, Print each SQ Item
68 for(ListSQItem::iterator cc = items.begin();cc != items.end();++cc)
73 // at end, print the sequence terminator item, if any
75 for (int i=0;i<SQDepthLevel+1;i++)
77 if (seq_term != NULL) {
82 os << " -------------- should have a sequence terminator item";
87 * \brief canonical Writer
89 void gdcmSeqEntry::Write(FILE *fp, FileType filetype)
91 gdcmDocEntry::Write(fp, filetype);
92 for(ListSQItem::iterator cc = GetSQItems().begin();
93 cc != GetSQItems().end();
96 (*cc)->Write(fp, filetype);
100 //-----------------------------------------------------------------------------
103 /// \brief adds the passed ITEM to the ITEM chained List for this SeQuence.
104 void gdcmSeqEntry::AddEntry(gdcmSQItem *sqItem, int itemNumber) {
105 sqItem->SetSQItemNumber(itemNumber);
106 items.push_back(sqItem);
109 /// \brief Sets the depth level of a Sequence Entry embedded in a SeQuence
110 void gdcmSeqEntry::SetDepthLevel(int depth) {
111 SQDepthLevel = depth;
114 /// \brief return a pointer to the SQItem referenced by its ordinal number
115 /// (returns the first one if ordinal number is <0
116 /// returns the last one if ordinal number is > item number
118 gdcmSQItem *gdcmSeqEntry::GetSQItemByOrdinalNumber(int nb) {
120 return (*(items.begin()));
122 for(ListSQItem::iterator cc = items.begin();
128 return (*(items.end())); // Euhhhhh ?!? Is this the last one . FIXME
130 //-----------------------------------------------------------------------------
134 //-----------------------------------------------------------------------------
137 //-----------------------------------------------------------------------------