]> Creatis software - gdcm.git/blob - src/gdcmDicomDirStudy.cxx
92630664ab69bbbccbea9ec1f4dcf4e2ff6db468
[gdcm.git] / src / gdcmDicomDirStudy.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDicomDirStudy.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/01/18 14:28:32 $
7   Version:   $Revision: 1.27 $
8                                                                                 
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.html for details.
12                                                                                 
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.
16                                                                                 
17 =========================================================================*/
18
19 #include "gdcmDicomDirStudy.h"
20 #include "gdcmDicomDirElement.h"
21 #include "gdcmGlobal.h"
22 #include "gdcmDicomDirSerie.h"
23 #include "gdcmDebug.h"
24
25 namespace gdcm 
26 {
27 //-----------------------------------------------------------------------------
28 // Constructor / Destructor
29 /**
30  * \brief  Constructor 
31  */
32 DicomDirStudy::DicomDirStudy():
33    DicomDirObject()
34 {
35 }
36 /**
37  * \brief   Canonical destructor.
38  */
39 DicomDirStudy::~DicomDirStudy() 
40 {
41    for(ListDicomDirSerie::iterator cc = Series.begin();
42                                    cc != Series.end();
43                                  ++cc )
44    {
45       delete *cc;
46    }
47 }
48
49 //-----------------------------------------------------------------------------
50 // Print
51 /**
52  * \brief   Prints the Object
53  * @param os ostream to write to 
54  * @param   indent indent
55  * @return
56  */ 
57 void DicomDirStudy::Print(std::ostream &os, std::string const & )
58 {
59    os << "STUDY" << std::endl;
60    DicomDirObject::Print(os);
61
62    for(ListDicomDirSerie::iterator cc = Series.begin();
63                                    cc != Series.end();
64                                    ++cc)
65    {
66       (*cc)->SetPrintLevel(PrintLevel);
67       (*cc)->Print(os);
68    }
69 }
70
71 //-----------------------------------------------------------------------------
72 // Public
73
74 /**
75  * \brief   Writes the Object
76  * @param fp ofstream to write to
77  * @param t Type of the File (explicit VR, implicitVR, ...) 
78  * @return
79  */ 
80 void DicomDirStudy::WriteContent(std::ofstream *fp, FileType t)
81 {
82    DicomDirObject::WriteContent(fp, t);
83
84    for(ListDicomDirSerie::iterator cc = Series.begin();
85                                    cc!= Series.end();
86                                  ++cc )
87    {
88       (*cc)->WriteContent( fp, t );
89    }
90 }
91
92 /**
93  * \brief   adds a new Serie at the begining of the SerieList
94  *          of a partially created DICOMDIR
95  */
96 DicomDirSerie *DicomDirStudy::NewSerie()
97 {
98    ListDicomDirSerieElem const &elemList = 
99       Global::GetDicomDirElements()->GetDicomDirSerieElements();   
100
101    DicomDirSerie* st = new DicomDirSerie();
102    FillObject(elemList);
103    Series.push_front(st);
104
105    return st;  
106
107
108  /**
109  * \brief   Get the first entry while visiting the DicomDirSeries
110  * \return  The first DicomDirSerie if found, otherwhise NULL
111  */
112 DicomDirSerie *DicomDirStudy::GetFirstEntry()
113 {
114    ItDicomDirSerie = Series.begin();
115    if (ItDicomDirSerie != Series.end())
116       return *ItDicomDirSerie;
117    return NULL;
118 }
119
120 /**
121  * \brief   Get the next entry while visiting the DicomDirSeries
122  * \note : meaningfull only if GetFirstEntry already called
123  * \return  The next DicomDirSerie if found, otherwhise NULL
124  */
125 DicomDirSerie *DicomDirStudy::GetNextEntry()
126 {
127    gdcmAssertMacro (ItDicomDirSerie != Series.end());
128    {
129       ++ItDicomDirSerie;
130       if (ItDicomDirSerie != Series.end())
131          return *ItDicomDirSerie;
132    }
133    return NULL;
134 }  
135 //-----------------------------------------------------------------------------
136 // Protected
137
138 //-----------------------------------------------------------------------------
139 // Private
140
141 //-----------------------------------------------------------------------------
142 } // end namespace gdcm
143