]> Creatis software - gdcm.git/blob - src/gdcmDocEntrySet.h
Fix mistypings
[gdcm.git] / src / gdcmDocEntrySet.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDocEntrySet.h,v $
5   Language:  C++
6   Date:      $Date: 2007/09/17 12:16:02 $
7   Version:   $Revision: 1.73 $
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 "gdcmRefCounter.h"
23 #include "gdcmVRKey.h"
24 #include "gdcmTagKey.h"
25
26 #include <fstream>
27
28 namespace GDCM_NAME_SPACE 
29 {
30 //-----------------------------------------------------------------------------
31 class DocEntry;
32 class DataEntry;
33 class SeqEntry;
34 class DictEntry;
35
36 //-----------------------------------------------------------------------------
37 /**
38  * \brief
39  *  DocEntrySet is an abstract base class for ElementSet, SQItem
40  *  which are both containers for DocEntries.
41  *  -  ElementSet is based on the STL map<> container
42  * (see  ElementSet::TagHT)
43  *  -  SQItem is based on an STL list container (see  ListDocEntry).
44  *
45  * Since the syntax for adding a new element to a map<> or a list<>
46  * differ,  DocEntrySet is designed as an adapter to unify the
47  * interfaces of  DocEntrySet and  ElementSet.
48  *
49  * As an illustration of this design, please refer to the implementation
50  * of  AddEntry (or any pure virtual method) in both derived classes.
51  * This adapter unification of interfaces enables the parsing of a
52  * DICOM header containing (optionaly heavily nested) sequences to be
53  * written recursively [see  Document::ParseDES 
54  * which calls  Document::ParseSQ, which in turn calls 
55  *  Document::ParseDES ].
56  *
57  * \note Developpers should strongly resist to the temptation of adding
58  *       members to this class since this class is designed as an adapter 
59  *       in the form of an abstract base class.
60  */
61 class GDCM_EXPORT DocEntrySet : public RefCounter
62 {
63    gdcmTypeMacro(DocEntrySet);
64
65 public:
66    /// \brief write any type of entry to the entry set
67    virtual void WriteContent (std::ofstream *fp, FileType filetype,
68                                bool insideMetaElements,bool insideSequence ) = 0;
69
70    /// \brief Remove all Entry of the current set
71    virtual void ClearEntry() = 0;
72    /// \brief adds any type of entry to the current set
73    virtual bool AddEntry(DocEntry *entry) = 0;
74    /// \brief Removes any type of entry out of the entry set, and destroys it
75    virtual bool RemoveEntry(DocEntry *entryToRemove) = 0;
76    /// \brief Gets the first entry (of any type) of the current set
77    virtual DocEntry *GetFirstEntry()=0;
78    /// \brief Gets the next entry (of any type) of the current set
79    virtual DocEntry *GetNextEntry()=0;
80
81    virtual std::string GetEntryString(uint16_t group, uint16_t elem);
82    virtual void *GetEntryBinArea(uint16_t group, uint16_t elem);
83    virtual int GetEntryLength(uint16_t group, uint16_t elem);
84
85    /// \brief Gets any type of DocEntry, identified by its (group,elem)
86    virtual DocEntry *GetDocEntry(uint16_t group, uint16_t elem) = 0;
87    /// \brief Gets a DataEntry, identified by its (group, elem)
88    DataEntry *GetDataEntry(uint16_t group, uint16_t elem);
89    /// \brief Gets a SeqEntry, identified by its (group,elem)
90    SeqEntry *GetSeqEntry(uint16_t group, uint16_t elem);
91
92    bool SetEntryString(std::string const &content,
93                        uint16_t group, uint16_t elem);
94    bool SetEntryBinArea(uint8_t *content, int lgth,
95                         uint16_t group, uint16_t elem);
96    bool SetEntryString(std::string const &content, DataEntry *entry);
97    bool SetEntryBinArea(uint8_t *content, int lgth, DataEntry *entry);
98
99    DataEntry *InsertEntryString(std::string const &value,
100                                    uint16_t group, uint16_t elem,
101                                    VRKey const &vr = GDCM_VRUNKNOWN);
102    DataEntry *InsertEntryBinArea(uint8_t *binArea, int lgth,
103                                     uint16_t group, uint16_t elem,
104                                     VRKey const &vr = GDCM_VRUNKNOWN);
105    SeqEntry *InsertSeqEntry(uint16_t group, uint16_t elem);
106    /// \brief Tells us if the set contains no entry
107    virtual bool IsEmpty() = 0;
108    virtual bool CheckIfEntryExist(uint16_t group, uint16_t elem);
109
110 // DocEntry  related utilities 
111    DataEntry *NewDataEntry(uint16_t group,uint16_t elem,
112                          VRKey const &vr = GDCM_VRUNKNOWN);
113    SeqEntry *NewSeqEntry(uint16_t group, uint16_t elem);
114
115    virtual void Copy(DocEntrySet *) {};
116
117 protected:
118    /// Canonical Constructor
119    DocEntrySet();
120    /// Canonical Destructor
121    virtual ~DocEntrySet() {}
122
123 // DictEntry  related utilities
124    DictEntry *GetDictEntry(uint16_t group, uint16_t elem);
125  //  DictEntry *GetDictEntry(uint16_t group, uint16_t elem,
126  //                          VRKey const &vr);
127    /// To be able to backtrack (Private Sequence, Implicit VR related pb)
128    DocEntry *PreviousDocEntry;
129
130 private:
131 };
132
133 } // end namespace gdcm
134 //-----------------------------------------------------------------------------
135 #endif
136