1 /*=========================================================================
4 Module: $RCSfile: gdcmDocEntrySet.h,v $
6 Date: $Date: 2005/11/28 15:20:33 $
7 Version: $Revision: 1.64 $
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.
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.
17 =========================================================================*/
19 #ifndef GDCMDOCENTRYSET_H
20 #define GDCMDOCENTRYSET_H
22 #include "gdcmCommandManager.h"
23 #include "gdcmVRKey.h"
24 #include "gdcmTagKey.h"
30 //-----------------------------------------------------------------------------
36 //-----------------------------------------------------------------------------
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)
43 * - \ref SQItem is based on an STL list container (see \ref ListDocEntry).
45 * Since the syntax for adding a new element to a map<> or a list<>
46 * differ, \ref DocEntrySet is designed as an adapter to unify the
47 * interfaces of \ref DocEntrySet and \ref ElementSet.
49 * As an illustration of this design, please refer to the implementation
50 * of \ref 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 \ref Document::ParseDES
54 * which calls \ref Document::ParseSQ, which in turn calls
55 * \ref Document::ParseDES ].
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.
61 class GDCM_EXPORT DocEntrySet : public CommandManager
63 gdcmTypeMacro(DocEntrySet);
66 /// \brief write any type of entry to the entry set
67 virtual void WriteContent (std::ofstream *fp, FileType filetype) = 0;
69 /// \brief Remove all Entry of the current set
70 virtual void ClearEntry() = 0;
71 /// \brief adds any type of entry to the current set
72 virtual bool AddEntry(DocEntry *entry) = 0;
73 /// \brief Removes any type of entry out of the entry set, and destroys it
74 virtual bool RemoveEntry(DocEntry *entryToRemove) = 0;
75 /// \brief Gets the first entry (of any type) of the current set
76 virtual DocEntry *GetFirstEntry()=0;
77 /// \brief Gets the next entry (of any type) of the current set
78 virtual DocEntry *GetNextEntry()=0;
80 virtual std::string GetEntryString(uint16_t group, uint16_t elem);
81 virtual void *GetEntryBinArea(uint16_t group, uint16_t elem);
82 virtual int GetEntryLength(uint16_t group, uint16_t elem);
84 /// \brief Gets any type of DocEntry, identified by its (group,elem)
85 virtual DocEntry *GetDocEntry(uint16_t group, uint16_t elem) = 0;
86 /// \brief Gets a DataEntry, identified by its (group, elem)
87 DataEntry *GetDataEntry(uint16_t group, uint16_t elem);
88 /// \brief Gets a SeqEntry, identified by its (group,elem)
89 SeqEntry *GetSeqEntry(uint16_t group, uint16_t elem);
91 bool SetEntryString(std::string const &content,
92 uint16_t group, uint16_t elem);
93 bool SetEntryBinArea(uint8_t *content, int lgth,
94 uint16_t group, uint16_t elem);
95 bool SetEntryString(std::string const &content, DataEntry *entry);
96 bool SetEntryBinArea(uint8_t *content, int lgth, DataEntry *entry);
98 DataEntry *InsertEntryString(std::string const &value,
99 uint16_t group, uint16_t elem,
100 VRKey const &vr = GDCM_VRUNKNOWN);
101 DataEntry *InsertEntryBinArea(uint8_t *binArea, int lgth,
102 uint16_t group, uint16_t elem,
103 VRKey const &vr = GDCM_VRUNKNOWN);
104 SeqEntry *InsertSeqEntry(uint16_t group, uint16_t elem);
105 /// \brief Tells us if the set contains no entry
106 virtual bool IsEmpty() = 0;
107 virtual bool CheckIfEntryExist(uint16_t group, uint16_t elem);
109 // DocEntry related utilities
110 DataEntry *NewDataEntry(uint16_t group,uint16_t elem,
111 VRKey const &vr = GDCM_VRUNKNOWN);
112 SeqEntry *NewSeqEntry(uint16_t group, uint16_t elem);
115 /// Canonical Constructor
117 /// Canonical Destructor
118 virtual ~DocEntrySet() {}
120 // DictEntry related utilities
121 DictEntry *GetDictEntry(uint16_t group, uint16_t elem);
122 DictEntry *GetDictEntry(uint16_t group, uint16_t elem,
124 /// To be able to backtrack (Private Sequence, Implicit VR related pb)
125 DocEntry *PreviousDocEntry;
130 } // end namespace gdcm
131 //-----------------------------------------------------------------------------