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