gdcmDataEntry.h

Go to the documentation of this file.
00001 /*=========================================================================
00002                                                                                 
00003   Program:   gdcm
00004   Module:    $RCSfile: gdcmDataEntry.h,v $
00005   Language:  C++
00006   Date:      $Date: 2007/08/22 16:14:03 $
00007   Version:   $Revision: 1.19 $
00008                                                                                 
00009   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
00010   l'Image). All rights reserved. See Doc/License.txt or
00011   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
00012                                                                                 
00013      This software is distributed WITHOUT ANY WARRANTY; without even
00014      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00015      PURPOSE.  See the above copyright notices for more information.
00016                                                                                 
00017 =========================================================================*/
00018 
00019 #ifndef G_DCMDATAENTRY_H_
00020 #define _GDCMDATAENTRY_H_
00021 
00022 #include "gdcmDocEntry.h"
00023 
00024 #include <vector> // for GetDSValue
00025 #include <iostream>
00026 
00027 namespace GDCM_NAME_SPACE 
00028 {
00029 //-----------------------------------------------------------------------------
00037 class GDCM_EXPORT DataEntry  : public DocEntry
00038 {
00039    gdcmTypeMacro(DataEntry);
00040 
00041 public:
00043 //   static DataEntry *New(DictEntry *e) {return new DataEntry(e);}
00045    static DataEntry *New(DocEntry *d)  {return new DataEntry(d);}
00047    static DataEntry *New(uint16_t group,uint16_t elem, VRKey const &vr)  
00048            {return new DataEntry(group,elem,vr);}
00049    
00050 // Print
00051    void Print(std::ostream &os = std::cout, std::string const &indent = "");
00052 
00053 // Write
00054    virtual void WriteContent(std::ofstream *fp, FileType filetype,
00055                                                    bool insideMetaElements );
00056    uint32_t ComputeFullLength();
00057    
00058 // Set/Get data
00059    // Sets the value (string) of the current Dicom entry
00060    //virtual void SetValue(std::string const &val);
00061 
00064    uint8_t *GetBinArea()  { return BinArea; }
00065    void SetBinArea( uint8_t *area, bool self = true );
00066    void CopyBinArea( uint8_t *area, uint32_t length );
00067 
00068    void SetValue(const uint32_t &id,const double &val);
00069    double GetValue(const uint32_t &id) const;
00070    uint32_t GetValueCount() const;
00071    bool IsValueCountValid() /*const*/; // GetVM may update the pointer DicomDict
00072 
00073    void SetString(std::string const &value);
00074    std::string const &GetString() const;
00075 
00077    void SetSelfArea(bool area) { SelfArea = area; }
00079    bool IsSelfArea() { return SelfArea; }
00080 
00082    enum TValueState
00083    {
00084       STATE_LOADED    = 0x00,
00085       STATE_NOTLOADED = 0x01,
00086       STATE_UNFOUND   = 0x02,
00087       STATE_UNREAD    = 0x03
00088    };
00089    
00091    enum TValueFlag
00092    {
00093       FLAG_NONE       = 0x00,
00094       FLAG_PIXELDATA  = 0x01
00095    };
00096 
00097    // State
00099    void SetState(const TValueState &state) { State = state; }
00101    const TValueState &GetState() const { return State; }
00103    bool IsNotLoaded() { return State == STATE_NOTLOADED; }
00105    bool IsUnfound()   { return State == STATE_UNFOUND; }
00107    bool IsUnread()    { return State == STATE_UNREAD; }
00109    bool IsGoodValue() { return State == STATE_LOADED; }
00110 
00111    // Flags
00113    void SetFlag(const TValueFlag &flag) { Flag = flag; }
00115    const TValueFlag &GetFlag() const { return Flag; }
00117    bool IsPixelData() { return (Flag &FLAG_PIXELDATA) != 0; }
00118 
00119    virtual void Copy(DocEntry *doc);
00120 
00123    static const uint32_t &GetMaxSizePrintEntry() { return MaxSizePrintEntry; }
00125    static void SetMaxSizePrintEntry(const uint32_t &size) 
00126                                                  { MaxSizePrintEntry = size; }
00127 
00128    bool GetDSValue(std::vector <double> &valueVector);
00129 
00130 protected:
00131   // DataEntry(DictEntry *e);
00132    DataEntry(DocEntry *d);
00133    DataEntry(uint16_t group,uint16_t elem,VRKey const &vr); 
00134    ~DataEntry();
00135 
00136 // Methods :
00137    void NewBinArea( );
00138    void DeleteBinArea( );
00139 
00140 // Members :
00143    uint8_t *BinArea;
00145    bool SelfArea;
00148    //mutable std::string StrArea;
00149    mutable std::string *StrArea; // to avoid allocating useless std::string
00150 
00151 private:
00153    TValueFlag Flag;
00155    TValueState State;
00156 
00158    static uint32_t MaxSizePrintEntry;   
00159 };
00160 
00161 } // end namespace gdcm
00162 
00163 //-----------------------------------------------------------------------------
00164 #endif
00165 

Generated on Fri Aug 24 12:59:29 2007 for gdcm by  doxygen 1.4.6