]> Creatis software - gdcm.git/blob - src/gdcmDicomDirSerie.cxx
ENH: Removed all FILE* ref and replace by ifstream/ofstream. For now I use a temp...
[gdcm.git] / src / gdcmDicomDirSerie.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDicomDirSerie.cxx,v $
5   Language:  C++
6   Date:      $Date: 2004/10/22 03:05:41 $
7   Version:   $Revision: 1.18 $
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 "gdcmGlobal.h"
22
23 namespace gdcm 
24 {
25
26 //-----------------------------------------------------------------------------
27 // Constructor / Destructor
28 /**
29  * \brief  Constructor 
30  * @param  s  SQ Item holding the elements related to this "SERIE" part
31  * @param ptagHT pointer to the HTable (DicomDirObject needs it 
32  *               to build the DocEntries)
33  */
34 DicomDirSerie::DicomDirSerie(SQItem* s, TagDocEntryHT* ptagHT):
35    DicomDirObject(ptagHT)
36 {
37    docEntries = s->GetDocEntries();
38 }
39
40 /**
41  * \brief  Constructor 
42  * @param ptagHT pointer to the HTable (DicomDirObject needs it 
43  *               to build the DocEntries)
44  */
45 DicomDirSerie::DicomDirSerie(TagDocEntryHT* ptagHT):
46    DicomDirObject(ptagHT)
47 {
48 }
49 /**
50  * \brief   Canonical destructor.
51  */
52 DicomDirSerie::~DicomDirSerie() 
53 {
54    for(ListDicomDirImage::iterator cc = images.begin();
55                                    cc != images.end();
56                                    ++cc)
57    {
58       delete *cc;
59    }
60 }
61
62 //-----------------------------------------------------------------------------
63 // Print
64 /**
65  * \brief   Prints the Object
66  * @return
67  */ 
68 void DicomDirSerie::Print(std::ostream& os)
69 {
70    os << "SERIE" << std::endl;
71    DicomDirObject::Print(os);
72
73    for(ListDicomDirImage::iterator cc = images.begin();
74                                    cc != images.end();
75                                    ++cc)
76    {
77       (*cc)->SetPrintLevel(PrintLevel);
78       (*cc)->Print(os);
79    }
80 }
81
82 //-----------------------------------------------------------------------------
83 // Public
84
85 /**
86  * \brief   Writes the Object
87  * @return
88  */ 
89 void DicomDirSerie::Write(std::ofstream* fp, FileType t)
90 {
91    DicomDirObject::Write(fp, t);
92
93    for(ListDicomDirImage::iterator cc = images.begin();cc!=images.end();++cc)
94    {
95       (*cc)->Write( fp, t );
96    }
97 }
98
99 /**
100  * \brief   adds a new Image (with the basic elements) to a partially created DICOMDIR
101  */
102 DicomDirImage* DicomDirSerie::NewImage()
103 {
104    std::list<Element> elemList = 
105       Global::GetDicomDirElements()->GetDicomDirImageElements();
106
107    DicomDirImage* st = new DicomDirImage(PtagHT);
108    FillObject(elemList);
109    images.push_front(st);
110
111    return st;   
112
113 //-----------------------------------------------------------------------------
114 // Protected
115
116 //-----------------------------------------------------------------------------
117 // Private
118
119 //-----------------------------------------------------------------------------
120 } // end namespace gdcm
121
122