]> Creatis software - gdcm.git/blob - src/gdcmSQItem.h
e7c230ac00f0d029061a3c019847d191d0662f16
[gdcm.git] / src / gdcmSQItem.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmSQItem.h,v $
5   Language:  C++
6   Date:      $Date: 2005/01/20 11:39:49 $
7   Version:   $Revision: 1.34 $
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 #ifndef GDCMSQITEM_H
19 #define GDCMSQITEM_H
20
21 #include "gdcmDocEntrySet.h"
22 #include "gdcmElementSet.h"
23
24 #include <list>
25 #include <fstream>
26
27 namespace gdcm 
28 {
29 class DocEntry;
30
31 //-----------------------------------------------------------------------------
32 typedef std::list<DocEntry *> ListDocEntry;
33 //-----------------------------------------------------------------------------
34 /**
35  * \brief a SeqEntry is composed by a set of SQItems.
36  *        Each SQItem is composed by a set of DocEntry
37  *        A DocEntry may be a SeqEntry
38  *        ... and so forth 
39  */ 
40 class GDCM_EXPORT SQItem : public DocEntrySet 
41 {
42 public:
43    SQItem(int depthLevel);
44    ~SQItem();
45
46    virtual void Print(std::ostream &os = std::cout, std::string const & indent = "" ); 
47    void WriteContent(std::ofstream *fp, FileType filetype);
48
49    /// \brief   returns the DocEntry chained List for this SQ Item.
50    ListDocEntry const &GetDocEntries() const { return DocEntries; };
51    
52    /// \brief   adds the passed DocEntry to the DocEntry chained List for
53    /// this SQ Item.      
54    bool AddEntry(DocEntry *Entry); // add to the List
55    bool RemoveEntry(DocEntry *EntryToRemove);
56    bool RemoveEntryNoDestroy(DocEntry *EntryToRemove);
57   
58    DocEntry *GetDocEntry(uint16_t group, uint16_t elem);
59    ValEntry *GetValEntry(uint16_t group, uint16_t elem); 
60    BinEntry *GetBinEntry(uint16_t group, uint16_t elem); 
61    SeqEntry *GetSeqEntry(uint16_t group, uint16_t elem); 
62    
63    bool SetEntry(std::string const &val, uint16_t group, 
64                                          uint16_t elem);
65     
66    std::string GetEntry(uint16_t group, uint16_t elem);
67
68    /// \brief   returns the ordinal position of a given SQItem
69    int GetSQItemNumber() { return SQItemNumber; };
70
71    /// \brief   Sets the ordinal position of a given SQItem
72    void SetSQItemNumber(int itemNumber) { SQItemNumber = itemNumber; };
73
74    ///  \brief Accessor on \ref SQDepthLevel.
75    int GetDepthLevel() { return SQDepthLevel; }
76                                                                                 
77    ///  \brief Accessor on \ref SQDepthLevel.
78    void SetDepthLevel(int depth) { SQDepthLevel = depth; }
79
80    ///  \brief Accessor on \ref BaseTagKey.
81    void SetBaseTagKey( BaseTagKey const &key ) { BaseTagKeyNested = key; }
82
83    ///  \brief Accessor on \ref BaseTagKey.
84    BaseTagKey const &GetBaseTagKey() const { return BaseTagKeyNested; }
85
86    DocEntry *GetFirstEntry();
87    DocEntry *GetNextEntry();
88
89 protected:
90 // Variables that need to be access in subclasses
91
92    /// \brief Chained list of (Elementary) Doc Entries
93    ListDocEntry DocEntries;
94    /// Chained list iterator, used to visit the TagHT variable
95    ListDocEntry::iterator ItDocEntries;
96    
97    /// \brief pointer to the HTable of the Document,
98    ///       (because we don't know it within any DicomDirObject nor any SQItem)
99    // TagDocEntryHT *PtagHT;
100
101 private:
102
103    /// \brief Sequences can be nested. This \ref SQDepthLevel represents
104    ///        the level of the nesting of instances of this class.
105    ///        \ref SQDepthLevel and its \ref SeqEntry::SQDepthLevel
106    ///        counterpart are only defined on printing purposes
107    ///        (see \ref Print).
108    int SQDepthLevel;
109
110    /// \brief A TagKey of a DocEntry nested in a sequence is prepended
111    ///        with this BaseTagKey.
112    BaseTagKey BaseTagKeyNested;
113
114    /// \brief SQ Item ordinal number 
115    int SQItemNumber;
116 };
117 } // end namespace gdcm
118 //-----------------------------------------------------------------------------
119 #endif