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