]> Creatis software - gdcm.git/blob - src/gdcmDocEntrySet.h
* src/*.cxx *.h Reference to License.htm fixed to License.html.
[gdcm.git] / src / gdcmDocEntrySet.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDocEntrySet.h,v $
5   Language:  C++
6   Date:      $Date: 2004/09/27 08:39:06 $
7   Version:   $Revision: 1.19 $
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 "gdcmDocEntry.h"
24  
25 typedef std::string gdcmBaseTagKey;
26 //-----------------------------------------------------------------------------
27
28 /**
29  * \ref gdcmDocEntrySet is an abstract base class for \ref gdcmElementSet
30  * and \ref gdcmSQItem which are both containers for gdcmDocEntries.
31  * \ref gdcmElementSet is based on the STL map<> container
32  * (see \ref gdcmElementSet::TagHT), as opposed to \ref gdcmSQItem
33  * which is based on an STL list container (see \ref gdcmSQItem::docEntries).
34  * Since the syntax for adding a new element to a map<> or a list<>
35  * differ, \ref gdcmDocEntrySet is designed as an adapter to unify the
36  * interfaces of \ref gdcmDocEntrySet and \ref gdcmElementSet.
37  * As an illustration of this design, please refer to the implementation
38  * of \ref AddEntry (or any pure virtual method) in both derived classes.
39  * This adapter unification of interfaces enables the parsing of a
40  * DICOM header containing (optionaly heavily nested) sequences to be
41  * written recursively [see \ref gdcmDocument::ParseDES 
42  * which calls \ref gdcmDocument::ParseSQ, which in turns calls 
43  * \ref gdcmDocument::ParseDES ].
44  *
45  * \note Developpers should strongly resist to the temptation of adding
46  *       members to this class since this class is designed as an adapter 
47  *       in the form of an abstract base class.
48  */
49 class GDCM_EXPORT gdcmDocEntrySet
50 {
51 public:
52
53    gdcmDocEntrySet() {}
54    virtual ~gdcmDocEntrySet() {}
55
56    /// \brief adds any type of entry to the entry set (pure vitual)
57    virtual bool AddEntry(gdcmDocEntry *Entry) = 0; // pure virtual
58  
59    /// \brief prints any type of entry to the entry set (pure vitual)
60    virtual void Print (std::ostream & os = std::cout) = 0;// pure virtual
61
62    /// \brief write any type of entry to the entry set
63    virtual void Write (FILE *fp, FileType filetype) = 0;// pure virtual
64
65    virtual gdcmDocEntry* GetDocEntryByNumber(uint16_t group,
66                                              uint16_t element) = 0;
67    gdcmDocEntry *GetDocEntryByName(std::string const & name);
68    virtual std::string GetEntryByNumber(uint16_t group,uint16_t element) = 0;
69    std::string GetEntryByName(TagName const & name);
70    gdcmDictEntry *NewVirtualDictEntry(uint16_t group, 
71                                       uint16_t element,
72                                       std::string const & vr     = "unkn",
73                                       std::string const & fourth = "unkn",
74                                       std::string const & name   = "unkn");
75   
76 protected:
77
78 // DocEntry  related utilities 
79    gdcmValEntry* NewValEntryByNumber(uint16_t group, 
80                                      uint16_t element);
81    gdcmBinEntry* NewBinEntryByNumber(uint16_t group, 
82                                      uint16_t element);
83    gdcmDocEntry* NewDocEntryByNumber(uint16_t group, 
84                                      uint16_t element); 
85    gdcmDocEntry* NewDocEntryByNumber(uint16_t group, 
86                                      uint16_t element,
87                                      std::string const & VR); 
88    gdcmDocEntry* NewDocEntryByName  (std::string const & name);
89    gdcmSeqEntry* NewSeqEntryByNumber(uint16_t group, 
90                                      uint16_t element);
91
92 // DictEntry  related utilities
93    gdcmDictEntry *GetDictEntryByName  (std::string const & name);
94    gdcmDictEntry *GetDictEntryByNumber(uint16_t, uint16_t);
95
96 };
97
98
99 //-----------------------------------------------------------------------------
100 #endif
101