1 /*=========================================================================
4 Module: $RCSfile: gdcmDocEntrySet.h,v $
6 Date: $Date: 2005/10/18 12:58:28 $
7 Version: $Revision: 1.58 $
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
23 #include "gdcmVRKey.h"
29 //-----------------------------------------------------------------------------
35 typedef TagKey BaseTagKey;
37 //-----------------------------------------------------------------------------
40 * \ref DocEntrySet is an abstract base class for \ref ElementSet
41 * and \ref SQItem which are both containers for DocEntries.
42 * - \ref ElementSet is based on the STL map<> container
43 * (see \ref ElementSet::TagHT)
44 * - \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.
48 * As an illustration of this design, please refer to the implementation
49 * of \ref AddEntry (or any pure virtual method) in both derived classes.
50 * This adapter unification of interfaces enables the parsing of a
51 * DICOM header containing (optionaly heavily nested) sequences to be
52 * written recursively [see \ref Document::ParseDES
53 * which calls \ref Document::ParseSQ, which in turns calls
54 * \ref Document::ParseDES ].
56 * \note Developpers should strongly resist to the temptation of adding
57 * members to this class since this class is designed as an adapter
58 * in the form of an abstract base class.
60 class GDCM_EXPORT DocEntrySet : public Base
63 /// Canonical Constructor
65 /// Canonical Destructor
66 virtual ~DocEntrySet() {}
68 /// \brief write any type of entry to the entry set
69 virtual void WriteContent (std::ofstream *fp, FileType filetype) = 0;
71 /// \brief Remove all Entry in the entry set
72 virtual void ClearEntry() = 0;
73 /// \brief adds any type of entry to the entry set
74 virtual bool AddEntry(DocEntry *entry) = 0;
75 /// \brief Removes any type of entry out of the entry set, and destroys it
76 virtual bool RemoveEntry(DocEntry *entryToRemove) = 0;
77 /// \brief Removes any type of entry out of the entry set, DOESN'T destroy it
78 virtual bool RemoveEntryNoDestroy(DocEntry *entryToRemove) = 0;
79 /// Gets the first entry of any type of set
80 virtual DocEntry *GetFirstEntry()=0;
81 /// Gets the next entry of any type of set
82 virtual DocEntry *GetNextEntry()=0;
84 virtual std::string GetEntryString(uint16_t group, uint16_t elem);
85 virtual void *GetEntryBinArea(uint16_t group, uint16_t elem);
86 virtual int GetEntryLength(uint16_t group, uint16_t elem);
87 virtual std::string GetEntryForcedAsciiValue(uint16_t group, uint16_t elem);
89 /// \brief Gets any type of DocEntry, identified by its (group,elem)
90 virtual DocEntry *GetDocEntry(uint16_t group, uint16_t elem) = 0;
91 /// \brief Gets a DataEntry, identified by its (group, elem)
92 DataEntry *GetDataEntry(uint16_t group, uint16_t elem);
93 /// \brief Gets a SeqEntry, identified by its (group,elem)
94 SeqEntry *GetSeqEntry(uint16_t group, uint16_t elem);
96 bool SetEntryString(std::string const &content,
97 uint16_t group, uint16_t elem);
98 bool SetEntryBinArea(uint8_t *content, int lgth,
99 uint16_t group, uint16_t elem);
100 bool SetEntryString(std::string const &content, DataEntry *entry);
101 bool SetEntryBinArea(uint8_t *content, int lgth, DataEntry *entry);
103 DataEntry *InsertEntryString(std::string const &value,
104 uint16_t group, uint16_t elem,
105 VRKey const &vr = GDCM_VRUNKNOWN);
106 DataEntry *InsertEntryBinArea(uint8_t *binArea, int lgth,
107 uint16_t group, uint16_t elem,
108 VRKey const &vr = GDCM_VRUNKNOWN);
109 SeqEntry *InsertSeqEntry(uint16_t group, uint16_t elem);
110 /// tells us if the set contains no entry
111 virtual bool IsEmpty() = 0;
112 virtual bool CheckIfEntryExist(uint16_t group, uint16_t elem);
114 // DocEntry related utilities
115 DataEntry *NewDataEntry(uint16_t group,uint16_t elem,
116 VRKey const &vr = GDCM_VRUNKNOWN);
117 SeqEntry *NewSeqEntry(uint16_t group, uint16_t elem);
119 // DictEntry related utilities
120 DictEntry *NewVirtualDictEntry(uint16_t group,uint16_t elem,
121 VRKey const &vr = GDCM_VRUNKNOWN,
122 TagName const &vm = GDCM_UNKNOWN,
123 TagName const &name = GDCM_UNKNOWN );
126 // DictEntry related utilities
127 DictEntry *GetDictEntry(uint16_t group, uint16_t elem);
128 DictEntry *GetDictEntry(uint16_t group, uint16_t elem,
130 /// To be able to backtrack (Private Sequence, Implicit VR related pb)
131 DocEntry *PreviousDocEntry;
136 } // end namespace gdcm
137 //-----------------------------------------------------------------------------