]> Creatis software - gdcm.git/blob - src/gdcmDocEntrySet.h
First stage of name normalisation : gdcm::File replace by gdcm::FileHelper
[gdcm.git] / src / gdcmDocEntrySet.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDocEntrySet.h,v $
5   Language:  C++
6   Date:      $Date: 2005/01/20 16:17:00 $
7   Version:   $Revision: 1.40 $
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 "gdcmBase.h"
23 #include "gdcmException.h"
24 #include <fstream>
25
26 namespace gdcm 
27 {
28 class DocEntry;
29 class ValEntry;
30 class BinEntry;
31 class SeqEntry;
32 class DictEntry;
33
34 typedef std::string BaseTagKey;
35 //-----------------------------------------------------------------------------
36
37 /**
38  * \brief
39  * \ref DocEntrySet is an abstract base class for \ref ElementSet
40  * and \ref SQItem which are both containers for DocEntries.
41  * \ref ElementSet is based on the STL map<> container
42  * (see \ref ElementSet::TagHT), as opposed to \ref SQItem
43  * which is based on an STL list container (see \ref ListDocEntry).
44  * Since the syntax for adding a new element to a map<> or a list<>
45  * differ, \ref DocEntrySet is designed as an adapter to unify the
46  * interfaces of \ref DocEntrySet and \ref ElementSet.
47  * As an illustration of this design, please refer to the implementation
48  * of \ref AddEntry (or any pure virtual method) in both derived classes.
49  * This adapter unification of interfaces enables the parsing of a
50  * DICOM header containing (optionaly heavily nested) sequences to be
51  * written recursively [see \ref Document::ParseDES 
52  * which calls \ref Document::ParseSQ, which in turns calls 
53  * \ref Document::ParseDES ].
54  *
55  * \note Developpers should strongly resist to the temptation of adding
56  *       members to this class since this class is designed as an adapter 
57  *       in the form of an abstract base class.
58  */
59 class GDCM_EXPORT DocEntrySet : public Base
60 {
61 friend class FileHelper;
62 public:
63    DocEntrySet() {};
64    virtual ~DocEntrySet() {};
65
66    // ------- '... =0;' stands for 'Pure Virtual'
67
68    /// \brief adds any type of entry to the entry set
69    virtual bool AddEntry(DocEntry *Entry) = 0;
70
71    /// \brief Removes any type of entry out of the entry set, and destroys it
72    virtual bool RemoveEntry(DocEntry *EntryToRemove)=0;
73
74    /// \brief Removes any type of entry out of the entry set, DOESN'T destroy it
75    virtual bool RemoveEntryNoDestroy(DocEntry *EntryToRemove)= 0;
76
77    /// \brief write any type of entry to the entry set
78    virtual void WriteContent (std::ofstream *fp, 
79                               FileType filetype) = 0;
80
81    /// \brief Gets any type of DocEntry, identified by its (group,elem)
82    virtual DocEntry *GetDocEntry(uint16_t group,
83                                  uint16_t elem) = 0;
84
85    /// \brief Gets a ValEntry, identified by its (group,elem)
86    virtual ValEntry *GetValEntry(uint16_t group,
87                                  uint16_t elem) = 0;
88    /// \brief Gets a BinEntry, identified by its (group,elem)
89    virtual BinEntry *GetBinEntry(uint16_t group,
90                                  uint16_t elem) = 0;
91
92    /// \brief Gets a SeqEntry, identified by its (group,elem)
93    virtual SeqEntry *GetSeqEntry(uint16_t group,
94                                  uint16_t elem) = 0;
95
96    /// \brief Gets the 'string value' of a ValEntry
97    ///        identified by its (group,elem) - Sorry for the name !...-
98    virtual std::string GetEntry(uint16_t group, uint16_t elem) = 0;
99
100    DictEntry *NewVirtualDictEntry(uint16_t group, 
101                                   uint16_t elem,
102                                   TagName const &vr     = GDCM_UNKNOWN,
103                                   TagName const &vm     = GDCM_UNKNOWN,
104                                   TagName const &name   = GDCM_UNKNOWN );
105
106 protected:
107 // DocEntry  related utilities 
108
109    ValEntry *NewValEntry(uint16_t group,uint16_t elem,
110                          TagName const &vr = GDCM_UNKNOWN);
111    BinEntry *NewBinEntry(uint16_t group,uint16_t elem,
112                          TagName const &vr = GDCM_UNKNOWN);
113    SeqEntry *NewSeqEntry(uint16_t group,uint16_t elem);
114
115 // DictEntry  related utilities
116    DictEntry *GetDictEntry(uint16_t group, uint16_t elem);
117    DictEntry *GetDictEntry(uint16_t group, uint16_t elem,
118                            TagName const &vr);
119 };
120
121 } // end namespace gdcm
122 //-----------------------------------------------------------------------------
123 #endif
124