]> Creatis software - gdcm.git/blob - src/gdcmDicomDirMeta.cxx
b008d0e54be55337ac555d9b4fcdb2bc85289e38
[gdcm.git] / src / gdcmDicomDirMeta.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDicomDirMeta.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/01/23 10:12:33 $
7   Version:   $Revision: 1.25 $
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 "gdcmDicomDirMeta.h"
20 #include "gdcmDocument.h"
21 #include "gdcmDocEntry.h"
22 #include "gdcmGlobal.h"
23
24 namespace gdcm 
25 {
26
27 //-----------------------------------------------------------------------------
28 // Constructor / Destructor
29
30 /**
31  * \brief  Constructor
32  */ 
33 DicomDirMeta::DicomDirMeta(bool empty):
34    DicomDirObject()
35 {
36    if( !empty )
37    {
38       ListDicomDirStudyElem const &elemList = 
39          Global::GetDicomDirElements()->GetDicomDirMetaElements();
40       FillObject(elemList);
41    }
42 }
43
44 /**
45  * \brief   Canonical destructor.
46  */
47 DicomDirMeta::~DicomDirMeta() 
48 {
49 }
50
51 //-----------------------------------------------------------------------------
52 // Print
53 /**
54  * \brief   Prints the Meta Elements
55  * @param os ostream to write to 
56  * @param indent Indentation string to be prepended during printing
57  */ 
58 void DicomDirMeta::Print(std::ostream &os, std::string const & )
59 {
60    os << "META" << std::endl;
61    // warning : META doesn't behave exactly like a Objet 
62    for (ListDocEntry::iterator i = DocEntries.begin();
63         i != DocEntries.end();
64         ++i)
65    {
66       (*i)->SetPrintLevel(PrintLevel);
67       (*i)->Print();
68       os << std::endl;
69    }
70 }
71
72
73 //-----------------------------------------------------------------------------
74 // Public
75
76
77 /**
78  * \brief   Writes the Meta Elements
79  * @param fp ofstream to write to
80  * @param t File Type 
81  * @return
82  */ 
83 void DicomDirMeta::WriteContent(std::ofstream *fp, FileType t)
84 {   
85    for (ListDocEntry::iterator i = DocEntries.begin();  
86                               i != DocEntries.end();
87                               ++i)
88    {
89       (*i)->WriteContent(fp, t);
90    }
91 }
92
93 //-----------------------------------------------------------------------------
94 // Protected
95
96 //-----------------------------------------------------------------------------
97 // Private
98
99 //-----------------------------------------------------------------------------
100 } // end namespace gdcm