]> Creatis software - gdcm.git/blob - src/gdcmDocEntrySet.h
ENH: Apply patch from ITK back to main CVS. Fix problem with gcc2.95, we may need...
[gdcm.git] / src / gdcmDocEntrySet.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDocEntrySet.h,v $
5   Language:  C++
6   Date:      $Date: 2004/11/30 16:24:31 $
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 #ifndef GDCMDOCENTRYSET_H
20 #define GDCMDOCENTRYSET_H
21
22 #include "gdcmException.h"
23 #include <fstream>
24
25 namespace gdcm 
26 {
27 class DocEntry;
28 class ValEntry;
29 class BinEntry;
30 class SeqEntry;
31 class DictEntry;
32
33 typedef std::string BaseTagKey;
34 //-----------------------------------------------------------------------------
35
36 /**
37  * \ref DocEntrySet is an abstract base class for \ref ElementSet
38  * and \ref SQItem which are both containers for DocEntries.
39  * \ref ElementSet is based on the STL map<> container
40  * (see \ref ElementSet::TagHT), as opposed to \ref SQItem
41  * which is based on an STL list container (see \ref ListDocEntry).
42  * Since the syntax for adding a new element to a map<> or a list<>
43  * differ, \ref DocEntrySet is designed as an adapter to unify the
44  * interfaces of \ref DocEntrySet and \ref ElementSet.
45  * As an illustration of this design, please refer to the implementation
46  * of \ref AddEntry (or any pure virtual method) in both derived classes.
47  * This adapter unification of interfaces enables the parsing of a
48  * DICOM header containing (optionaly heavily nested) sequences to be
49  * written recursively [see \ref Document::ParseDES 
50  * which calls \ref Document::ParseSQ, which in turns calls 
51  * \ref Document::ParseDES ].
52  *
53  * \note Developpers should strongly resist to the temptation of adding
54  *       members to this class since this class is designed as an adapter 
55  *       in the form of an abstract base class.
56  */
57 class GDCM_EXPORT DocEntrySet
58 {
59 public:
60    DocEntrySet() {};
61    virtual ~DocEntrySet() {};
62
63    /// \brief adds any type of entry to the entry set (pure vitual)
64    virtual bool AddEntry(DocEntry *Entry) = 0; // pure virtual
65  
66    /// \brief prints any type of entry to the entry set (pure vitual)
67    virtual void Print (std::ostream & os = std::cout) = 0;// pure virtual
68
69    /// \brief write any type of entry to the entry set
70    virtual void WriteContent (std::ofstream *fp, FileType filetype) = 0;// pure virtual
71
72    virtual DocEntry* GetDocEntryByNumber(uint16_t group,
73                                          uint16_t element) = 0;
74    DocEntry* GetDocEntryByName(TagName const & name);
75    virtual std::string GetEntryByNumber(uint16_t group, uint16_t element) = 0;
76    std::string GetEntryByName(TagName const & name);
77    DictEntry* NewVirtualDictEntry( uint16_t group, 
78                                    uint16_t element,
79                                    TagName const & vr     = "unkn",
80                                    TagName const & fourth = "unkn",
81                                    TagName const & name   = "unkn" );
82   
83 protected:
84
85 // DocEntry  related utilities 
86    ValEntry* NewValEntryByNumber(uint16_t group, 
87                                  uint16_t element);
88    BinEntry* NewBinEntryByNumber(uint16_t group, 
89                                  uint16_t element);
90    DocEntry* NewDocEntryByNumber(uint16_t group, 
91                                  uint16_t element); 
92    DocEntry* NewDocEntryByNumber(uint16_t group, 
93                                  uint16_t element,
94                                  TagName const & vr); 
95    DocEntry* NewDocEntryByName  (TagName const & name);
96    SeqEntry* NewSeqEntryByNumber(uint16_t group, 
97                                  uint16_t element);
98
99 // DictEntry  related utilities
100    DictEntry *GetDictEntryByName  (TagName const & name);
101    DictEntry *GetDictEntryByNumber(uint16_t, uint16_t);
102
103 };
104
105 } // end namespace gdcm
106 //-----------------------------------------------------------------------------
107 #endif
108