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