1 /*=========================================================================
4 Module: $RCSfile: gdcmDocEntrySet.h,v $
6 Date: $Date: 2005/01/26 11:42:02 $
7 Version: $Revision: 1.45 $
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
33 typedef std::string BaseTagKey;
34 //-----------------------------------------------------------------------------
38 * \ref DocEntrySet is an abstract base class for \ref ElementSet
39 * and \ref SQItem which are both containers for DocEntries.
40 * \ref ElementSet is based on the STL map<> container
41 * (see \ref ElementSet::TagHT), as opposed to \ref SQItem
42 * which is based on an STL list container (see \ref ListDocEntry).
43 * Since the syntax for adding a new element to a map<> or a list<>
44 * differ, \ref DocEntrySet is designed as an adapter to unify the
45 * interfaces of \ref DocEntrySet and \ref ElementSet.
46 * As an illustration of this design, please refer to the implementation
47 * of \ref AddEntry (or any pure virtual method) in both derived classes.
48 * This adapter unification of interfaces enables the parsing of a
49 * DICOM header containing (optionaly heavily nested) sequences to be
50 * written recursively [see \ref Document::ParseDES
51 * which calls \ref Document::ParseSQ, which in turns calls
52 * \ref Document::ParseDES ].
54 * \note Developpers should strongly resist to the temptation of adding
55 * members to this class since this class is designed as an adapter
56 * in the form of an abstract base class.
58 class GDCM_EXPORT DocEntrySet : public Base
62 virtual ~DocEntrySet() {};
64 /// \brief write any type of entry to the entry set
65 virtual void WriteContent (std::ofstream *fp, FileType filetype) = 0;
67 /// \brief Remove all Entry in the entry set
68 virtual void ClearEntry() = 0;
69 /// \brief adds any type of entry to the entry set
70 virtual bool AddEntry(DocEntry *Entry) = 0;
71 /// \brief Removes any type of entry out of the entry set, and destroys it
72 virtual bool RemoveEntry(DocEntry *EntryToRemove)=0;
73 /// \brief Removes any type of entry out of the entry set, DOESN'T destroy it
74 virtual bool RemoveEntryNoDestroy(DocEntry *EntryToRemove)= 0;
76 virtual DocEntry *GetFirstEntry()=0;
77 virtual DocEntry *GetNextEntry()=0;
79 virtual std::string GetEntryValue(uint16_t group, uint16_t elem);
80 virtual void *GetEntryBinArea(uint16_t group, uint16_t elem);
81 virtual int GetEntryLength(uint16_t group, uint16_t elem);
82 virtual std::string GetEntryVR(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 ValEntry, identified by its (group,elem)
87 virtual ValEntry *GetValEntry(uint16_t group,uint16_t elem);
88 /// \brief Gets a BinEntry, identified by its (group,elem)
89 virtual BinEntry *GetBinEntry(uint16_t group,uint16_t elem);
90 /// \brief Gets a SeqEntry, identified by its (group,elem)
91 virtual SeqEntry *GetSeqEntry(uint16_t group,uint16_t elem);
93 virtual bool SetValEntry(std::string const &content,
94 uint16_t group, uint16_t elem);
95 virtual bool SetBinEntry(uint8_t *content, int lgth,
96 uint16_t group, uint16_t elem);
97 virtual bool SetValEntry(std::string const &content, ValEntry *entry);
98 virtual bool SetBinEntry(uint8_t *content, int lgth, BinEntry *entry);
100 virtual ValEntry *InsertValEntry(std::string const &value,
101 uint16_t group, uint16_t elem,
102 TagName const &vr = GDCM_UNKNOWN);
103 virtual BinEntry *InsertBinEntry(uint8_t *binArea, int lgth,
104 uint16_t group, uint16_t elem,
105 TagName const &vr = GDCM_UNKNOWN);
106 virtual SeqEntry *InsertSeqEntry(uint16_t group, uint16_t elem);
108 virtual bool IsEmpty() = 0;
109 virtual bool CheckIfEntryExist(uint16_t group, uint16_t elem);
111 DictEntry *NewVirtualDictEntry(uint16_t group,uint16_t elem,
112 TagName const &vr = GDCM_UNKNOWN,
113 TagName const &vm = GDCM_UNKNOWN,
114 TagName const &name = GDCM_UNKNOWN );
116 // DocEntry related utilities
117 ValEntry *NewValEntry(uint16_t group,uint16_t elem,
118 TagName const &vr = GDCM_UNKNOWN);
119 BinEntry *NewBinEntry(uint16_t group,uint16_t elem,
120 TagName const &vr = GDCM_UNKNOWN);
121 SeqEntry *NewSeqEntry(uint16_t group,uint16_t elem);
124 // DictEntry related utilities
125 DictEntry *GetDictEntry(uint16_t group, uint16_t elem);
126 DictEntry *GetDictEntry(uint16_t group, uint16_t elem,
132 } // end namespace gdcm
133 //-----------------------------------------------------------------------------