]> Creatis software - gdcm.git/blob - src/gdcmDicomDirStudy.cxx
* src/gdcmDicomDir*.[h|cxx] : rename methods to be logik in their name.
[gdcm.git] / src / gdcmDicomDirStudy.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDicomDirStudy.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/01/20 11:09:23 $
7   Version:   $Revision: 1.28 $
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  * \brief   Writes the Object
75  * @param fp ofstream to write to
76  * @param t Type of the File (explicit VR, implicitVR, ...) 
77  * @return
78  */ 
79 void DicomDirStudy::WriteContent(std::ofstream *fp, FileType t)
80 {
81    DicomDirObject::WriteContent(fp, t);
82
83    for(ListDicomDirSerie::iterator cc = Series.begin();
84                                    cc!= Series.end();
85                                  ++cc )
86    {
87       (*cc)->WriteContent( fp, t );
88    }
89 }
90
91 /**
92  * \brief   adds a new Serie at the begining of the SerieList
93  *          of a partially created DICOMDIR
94  */
95 DicomDirSerie *DicomDirStudy::NewSerie()
96 {
97    ListDicomDirSerieElem const &elemList = 
98       Global::GetDicomDirElements()->GetDicomDirSerieElements();   
99
100    DicomDirSerie* st = new DicomDirSerie();
101    st->FillObject(elemList);
102
103    Series.push_back(st);
104    return st;
105
106
107 /**
108  * \brief   Get the first entry while visiting the DicomDirSeries
109  * \return  The first DicomDirSerie if found, otherwhise NULL
110  */
111 DicomDirSerie *DicomDirStudy::GetFirstSerie()
112 {
113    ItSerie = Series.begin();
114    if (ItSerie != Series.end())
115       return *ItSerie;
116    return NULL;
117 }
118
119 /**
120  * \brief   Get the next entry while visiting the DicomDirSeries
121  * \note : meaningfull only if GetFirstEntry already called
122  * \return  The next DicomDirSerie if found, otherwhise NULL
123  */
124 DicomDirSerie *DicomDirStudy::GetNextSerie()
125 {
126    gdcmAssertMacro (ItSerie != Series.end());
127    {
128       ++ItSerie;
129       if (ItSerie != Series.end())
130          return *ItSerie;
131    }
132    return NULL;
133 }  
134
135 /**
136  * \brief   Get the last entry while visiting the DicomDirSeries
137  * \return  The first DicomDirSerie if found, otherwhise NULL
138  */
139 DicomDirSerie *DicomDirStudy::GetLastSerie()
140 {
141    ItSerie = Series.end();
142    if (ItSerie != Series.begin())
143    {
144      --ItSerie;
145       return *ItSerie;
146    }
147    return NULL;
148 }
149
150 //-----------------------------------------------------------------------------
151 // Protected
152
153 //-----------------------------------------------------------------------------
154 // Private
155
156 //-----------------------------------------------------------------------------
157 } // end namespace gdcm
158