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