1 /*=========================================================================
4 Module: $RCSfile: gdcmDocEntrySet.h,v $
6 Date: $Date: 2007/09/17 12:16:02 $
7 Version: $Revision: 1.73 $
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 "gdcmRefCounter.h"
23 #include "gdcmVRKey.h"
24 #include "gdcmTagKey.h"
28 namespace GDCM_NAME_SPACE
30 //-----------------------------------------------------------------------------
36 //-----------------------------------------------------------------------------
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).
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.
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 ].
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 RefCounter
63 gdcmTypeMacro(DocEntrySet);
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;
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;
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);
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);
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);
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);
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);
115 virtual void Copy(DocEntrySet *) {};
118 /// Canonical Constructor
120 /// Canonical Destructor
121 virtual ~DocEntrySet() {}
123 // DictEntry related utilities
124 DictEntry *GetDictEntry(uint16_t group, uint16_t elem);
125 // DictEntry *GetDictEntry(uint16_t group, uint16_t elem,
127 /// To be able to backtrack (Private Sequence, Implicit VR related pb)
128 DocEntry *PreviousDocEntry;
133 } // end namespace gdcm
134 //-----------------------------------------------------------------------------