]> Creatis software - gdcm.git/blob - src/gdcmSQItem.h
ENH: Apply patch from ITK back to main CVS. Fix problem with gcc2.95, we may need...
[gdcm.git] / src / gdcmSQItem.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmSQItem.h,v $
5   Language:  C++
6   Date:      $Date: 2004/11/30 16:24:31 $
7   Version:   $Revision: 1.24 $
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 class GDCM_EXPORT SQItem : public DocEntrySet 
35 {
36 public:
37    SQItem(int depthLevel);
38    ~SQItem();
39
40    void Print(std::ostream &os = std::cout); 
41    void WriteContent(std::ofstream *fp, FileType filetype);
42
43    /// \brief   returns the DocEntry chained List for this SQ Item.
44    ListDocEntry const & GetDocEntries() const { return DocEntries; };
45    
46    /// \brief   adds the passed DocEntry to the DocEntry chained List for
47    /// this SQ Item.      
48    void AddDocEntry(DocEntry *e) { DocEntries.push_back(e); };
49
50    virtual bool AddEntry(DocEntry *Entry); // add to the List
51   
52    DocEntry *GetDocEntryByNumber(uint16_t group, uint16_t element);
53    // FIXME method to write
54    //DocEntry *GetDocEntryByName  (std::string Name);
55    
56    bool SetEntryByNumber(std::string const & val, uint16_t group, 
57                                                   uint16_t element);
58     
59    std::string GetEntryByNumber(uint16_t group, uint16_t element);
60
61    /// \brief   returns the ordinal position of a given SQItem
62    int GetSQItemNumber() { return SQItemNumber; };
63
64    /// \brief   Sets the ordinal position of a given SQItem
65    void SetSQItemNumber(int itemNumber) { SQItemNumber = itemNumber; };
66
67    /// Accessor on \ref SQDepthLevel.
68    int GetDepthLevel() { return SQDepthLevel; }
69                                                                                 
70    /// Accessor on \ref SQDepthLevel.
71    void SetDepthLevel(int depth) { SQDepthLevel = depth; }
72
73    /// Accessor on \ref BaseTagKey.
74    void SetBaseTagKey( BaseTagKey const & key ) { BaseTagKeyNested = key; }
75
76    /// Accessor on \ref BaseTagKey.
77    BaseTagKey const & GetBaseTagKey() const { return BaseTagKeyNested; }
78
79
80 protected:
81 // Variables that need to be access in subclasses
82
83    /// \brief chained list of (Elementary) Doc Entries
84    ListDocEntry DocEntries;
85    
86    ///\brief pointer to the HTable of the Document,
87    ///       (because we don't know it within any DicomDirObject nor any SQItem)
88    TagDocEntryHT *PtagHT;
89
90 private:
91
92    /// \brief Sequences can be nested. This \ref SQDepthLevel represents
93    ///        the level of the nesting of instances of this class.
94    ///        \ref SQDepthLevel and its \ref SeqEntry::SQDepthLevel
95    ///        counterpart are only defined on printing purposes
96    ///        (see \ref Print).
97    int SQDepthLevel;
98
99    /// \brief A TagKey of a DocEntry nested in a sequence is prepended
100    ///        with this BaseTagKey.
101    BaseTagKey BaseTagKeyNested;
102
103  
104    /// \brief SQ Item ordinal number 
105    int SQItemNumber;
106
107 };
108 } // end namespace gdcm
109 //-----------------------------------------------------------------------------
110 #endif