]> Creatis software - gdcm.git/blob - src/gdcmSeqEntry.h
Add Method ComputeFullLength(), to allow further computaion of element 0x0000
[gdcm.git] / src / gdcmSeqEntry.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmSeqEntry.h,v $
5   Language:  C++
6   Date:      $Date: 2005/11/07 09:46:36 $
7   Version:   $Revision: 1.37 $
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
19 #ifndef GDCMSQDOCENTRY_H
20 #define GDCMSQDOCENTRY_H
21
22 #include "gdcmDocEntry.h"
23
24 #include <list>
25
26 namespace gdcm 
27 {
28 class SQItem;
29 //-----------------------------------------------------------------------------
30 typedef std::list<SQItem *> ListSQItem;
31
32 //-----------------------------------------------------------------------------
33 /**
34  * \brief a SeqEntry (as opposed to a DataEntry) is a non elementary DocEntry.
35  *        It 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 SeqEntry : public DocEntry 
41 {
42    gdcmTypeMacro(SeqEntry);
43
44 public:
45    static SeqEntry *New(DictEntry *e) {return new SeqEntry(e);}
46    static SeqEntry *New(DocEntry *d, int depth) {return new SeqEntry(d,depth);}
47
48    void Print(std::ostream &os = std::cout, std::string const &indent = "" ); 
49    void WriteContent(std::ofstream *fp, FileType filetype);
50    uint32_t ComputeFullLength();
51      
52    void AddSQItem(SQItem *it, int itemNumber);
53    void ClearSQItem();
54    SQItem *GetFirstSQItem();
55    SQItem *GetNextSQItem();
56    SQItem *GetSQItem(int itemNumber);
57    unsigned int GetNumberOfSQItems();
58       
59    /// Sets the delimitor mode
60    void SetDelimitorMode(bool dm) { DelimitorMode = dm; }
61
62    
63    void SetDelimitationItem(DocEntry *e);
64
65    /// Gets the Sequence Delimitation Item
66    DocEntry *GetDelimitationItem()       { return SeqTerm;}
67
68    /// Gets the depth level
69    int GetDepthLevel() const { return SQDepthLevel; }
70    /// Sets the depth level of a Sequence Entry embedded in a SeQuence
71    void SetDepthLevel(int depth) { SQDepthLevel = depth; }
72
73 protected:
74
75 private:
76    SeqEntry( DictEntry *e);
77    SeqEntry( DocEntry *d, int depth );
78    ~SeqEntry();
79
80 // Variables
81    /// If this Sequence is in delimitor mode (length =0xffffffff) or not
82    bool DelimitorMode;
83    
84    /// Chained list of SQ Items
85    ListSQItem Items;
86    /// iterator on the SQItems of the current SeqEntry
87    ListSQItem::iterator ItSQItem;
88
89    /// sequence terminator item 
90    DocEntry *SeqTerm;
91
92    /// \brief Defines the depth level of this \ref SeqEntry inside
93    ///        the (optionaly) nested sequences. \ref SQDepthLevel
94    ///        and its \ref SQItem::SQDepthLevel counterpart
95    ///        are only defined on printing purposes (see \ref Print).
96    int SQDepthLevel;
97 };
98 } // end namespace gdcm
99 //-----------------------------------------------------------------------------
100 #endif
101