]> Creatis software - gdcm.git/blob - src/gdcmDicomDirSerie.cxx
Doxygenation (Print method)
[gdcm.git] / src / gdcmDicomDirSerie.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDicomDirSerie.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/01/18 14:28:32 $
7   Version:   $Revision: 1.30 $
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 "gdcmDicomDirSerie.h"
20 #include "gdcmDicomDirElement.h"
21 #include "gdcmDicomDirImage.h"
22 #include "gdcmGlobal.h"
23 #include "gdcmDebug.h"
24
25 namespace gdcm 
26 {
27
28 //-----------------------------------------------------------------------------
29 // Constructor / Destructor
30 /**
31  * \brief  Constructor 
32  */
33 DicomDirSerie::DicomDirSerie():
34    DicomDirObject()
35 {
36 }
37 /**
38  * \brief   Canonical destructor.
39  */
40 DicomDirSerie::~DicomDirSerie() 
41 {
42    for(ListDicomDirImage::iterator cc = Images.begin();
43                                    cc != Images.end();
44                                    ++cc)
45    {
46       delete *cc;
47    }
48 }
49
50 //-----------------------------------------------------------------------------
51 // Print
52 /**
53  * \brief   Prints the Object
54  * @param os ostream to write to
55  * @param   indent indent
56  */ 
57 void DicomDirSerie::Print(std::ostream &os, std::string const &)
58 {
59    os << "SERIE" << std::endl;
60    DicomDirObject::Print(os);
61
62    for(ListDicomDirImage::iterator cc = Images.begin();
63                                    cc != Images.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  */ 
79 void DicomDirSerie::WriteContent(std::ofstream *fp, FileType t)
80 {
81    DicomDirObject::WriteContent(fp, t);
82
83    for(ListDicomDirImage::iterator cc = Images.begin();
84                                    cc!= Images.end();
85                                  ++cc )
86    {
87       (*cc)->WriteContent( fp, t );
88    }
89 }
90
91 /**
92  * \brief   adds a new Image (with the basic elements) to a partially created DICOMDIR
93  */
94 DicomDirImage *DicomDirSerie::NewImage()
95 {
96    ListDicomDirImageElem const &elemList = 
97       Global::GetDicomDirElements()->GetDicomDirImageElements();
98
99    DicomDirImage *st = new DicomDirImage();
100    FillObject(elemList);
101    Images.push_front(st);
102
103    return st;   
104 }
105
106 /**
107  * \brief   Get the first entry while visiting the DicomDirImage
108  * \return  The first DicomDirImage if found, otherwhise NULL
109  */
110 DicomDirImage *DicomDirSerie::GetFirstEntry()
111 {
112    ItDicomDirImage = Images.begin();
113    if (ItDicomDirImage != Images.end())
114       return *ItDicomDirImage;
115    return NULL;
116 }
117
118 /**
119  * \brief   Get the next entry while visiting the DicomDirImages
120  * \note : meaningfull only if GetFirstEntry already called
121  * \return  The next DicomDirImages if found, otherwhise NULL
122  */
123 DicomDirImage *DicomDirSerie::GetNextEntry()
124 {
125    gdcmAssertMacro (ItDicomDirImage != Images.end());
126    {
127       ++ItDicomDirImage;
128       if (ItDicomDirImage != Images.end())      
129          return *ItDicomDirImage;
130    }
131    return NULL;
132 }
133  
134 //-----------------------------------------------------------------------------
135 // Protected
136
137 //-----------------------------------------------------------------------------
138 // Private
139
140 //-----------------------------------------------------------------------------
141 } // end namespace gdcm
142
143