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