X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmDataEntry.h;h=dbad01c2826c1a000ca4801a81759edc9549738e;hb=56ad78cdf3b5de32f0a94a38cd32ddc9f403ffc3;hp=f8882df901ee27266ed7a7692e3782b6378b9272;hpb=cb6cf86b2b3cc6b43d40561fb9552ebd19fdbc99;p=gdcm.git diff --git a/src/gdcmDataEntry.h b/src/gdcmDataEntry.h index f8882df9..dbad01c2 100644 --- a/src/gdcmDataEntry.h +++ b/src/gdcmDataEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDataEntry.h,v $ Language: C++ - Date: $Date: 2005/10/23 15:32:30 $ - Version: $Revision: 1.4 $ + Date: $Date: 2007/09/18 16:07:20 $ + Version: $Revision: 1.21 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -15,15 +15,16 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ - -#ifndef GDCMDATAENTRY_H -#define GDCMDATAENTRY_H + +#ifndef G_DCMDATAENTRY_H_ +#define _GDCMDATAENTRY_H_ #include "gdcmDocEntry.h" +#include // for GetDSValue #include -namespace gdcm +namespace GDCM_NAME_SPACE { //----------------------------------------------------------------------------- /** @@ -35,47 +36,71 @@ namespace gdcm */ class GDCM_EXPORT DataEntry : public DocEntry { -public: - DataEntry(DictEntry *e); - DataEntry(DocEntry *d); - ~DataEntry(); + gdcmTypeMacro(DataEntry); +public: +/// \brief Contructs a DataEntry with a RefCounter from DictEntry +// static DataEntry *New(DictEntry *e) {return new DataEntry(e);} +/// \brief Contructs a DataEntry with a RefCounter from DocEntry + static DataEntry *New(DocEntry *d) {return new DataEntry(d);} +/// \brief Contructs a DataEntry with a RefCounter from elementary items + static DataEntry *New(uint16_t group,uint16_t elem, VRKey const &vr) + {return new DataEntry(group,elem,vr);} + // Print void Print(std::ostream &os = std::cout, std::string const &indent = ""); // Write - virtual void WriteContent(std::ofstream *fp, FileType filetype); - + virtual void WriteContent(std::ofstream *fp, FileType filetype, + bool insideMetaElements, bool insideSequence); + uint32_t ComputeFullLength(); + // Set/Get data - /// Sets the value (string) of the current Dicom entry + // Sets the value (string) of the current Dicom entry //virtual void SetValue(std::string const &val); - /// \brief Returns the 'Value' (e.g. "Dupond^Marcel") converted - /// into a 'string', event if it's physically stored on disk as an integer - /// (e.g. : 0x000c returned as "12") - //virtual std::string const &GetValue() const { return Value; } /// \brief Returns the area value of the current Dicom Entry - /// when it's not string-translatable (e.g : LUT table, overlay, icon) + /// when it's not string-translatable (e.g : LUT table, overlay, icon) uint8_t *GetBinArea() { return BinArea; } void SetBinArea( uint8_t *area, bool self = true ); void CopyBinArea( uint8_t *area, uint32_t length ); void SetValue(const uint32_t &id,const double &val); double GetValue(const uint32_t &id) const; - uint32_t GetValueCount(void) const; - bool IsValueCountValid() const; + uint32_t GetValueCount() const; + bool IsValueCountValid() /*const*/; // GetVM may update the pointer DicomDict void SetString(std::string const &value); std::string const &GetString() const; + std::string const &GetHexaRepresentation() const; + /// \brief Sets SelfArea void SetSelfArea(bool area) { SelfArea = area; } /// \brief True if Entry owns its BinArea bool IsSelfArea() { return SelfArea; } + ///\brief values for current state of a DataEntry (internal use only) + enum TValueState + { + STATE_LOADED = 0x00, + STATE_NOTLOADED = 0x01, + STATE_UNFOUND = 0x02, + STATE_UNREAD = 0x03 + }; + + ///\brief values for current pixel status of a DataEntry (internal use only) + enum TValueFlag + { + FLAG_NONE = 0x00, + FLAG_PIXELDATA = 0x01 + }; + // State - void SetState(const char &state) { State = state; } - const char &GetState() const { return State; } + /// \brief Sets the state (Loaded, NotLoaded, UnFound, ...) of the DataEntry + void SetState(const TValueState &state) { State = state; } + /// \brief Returns the state (Loaded, NotLoaded, ...) of the DataEntry + const TValueState &GetState() const { return State; } /// \brief true when value Entry not loaded bool IsNotLoaded() { return State == STATE_NOTLOADED; } /// \brief true if Entry not found @@ -83,44 +108,36 @@ public: /// \brief true if Entry not read bool IsUnread() { return State == STATE_UNREAD; } /// \brief true if Entry value properly loaded - bool IsGoodValue() { return State == 0; } + bool IsGoodValue() { return State == STATE_LOADED; } // Flags /// \brief sets the 'pixel data flag' - void SetFlag(const char &flag) { Flag = flag; } - /// \brief returns the 'pixel data flag' - const char &GetFlag() const { return Flag; } + void SetFlag(const TValueFlag &flag) { Flag = flag; } + /// \brief returns the 'pixel data flag' + const TValueFlag &GetFlag() const { return Flag; } /// \brief true id Entry is a Pixel Data entry - bool IsPixelData() { return (Flag & FLAG_PIXELDATA) != 0; } + bool IsPixelData() { return (Flag &FLAG_PIXELDATA) != 0; } - void Copy(DocEntry *doc); + virtual void Copy(DocEntry *doc); /// \brief returns the size threshold above which an element value /// will NOT be *printed* in order no to polute the screen output static const uint32_t &GetMaxSizePrintEntry() { return MaxSizePrintEntry; } /// \brief Header Elements too long will not be printed - static void SetMaxSizePrintEntry(const uint32_t &size) { MaxSizePrintEntry = size; } + static void SetMaxSizePrintEntry(const uint32_t &size) + { MaxSizePrintEntry = size; } - ///\brief values for current state of a DataEntry (internal use only) - typedef enum - { - STATE_LOADED = 0x00, - STATE_NOTLOADED = 0x01, - STATE_UNFOUND = 0x02, - STATE_UNREAD = 0x03 - } TValueState; - - ///\brief values for current pixel status of a DataEntry (internal use only) - typedef enum - { - FLAG_NONE = 0x00, - FLAG_PIXELDATA = 0x01 - } TValueFlag; + bool GetDSValue(std::vector &valueVector); protected: + // DataEntry(DictEntry *e); + DataEntry(DocEntry *d); + DataEntry(uint16_t group,uint16_t elem,VRKey const &vr); + ~DataEntry(); + // Methods : - void NewBinArea(void); - void DeleteBinArea(void); + void NewBinArea( ); + void DeleteBinArea( ); // Members : /// \brief memory area to hold 'non std::string' representable values @@ -130,16 +147,18 @@ protected: bool SelfArea; /// \brief std::string representable value of the Entry. /// Parts of a multivaluated data are separated by back-slash - mutable std::string StrArea; + mutable std::string *StrArea; // to avoid allocating useless std::string + /// \brief std::string Hexadecimal represention of the value Entry. + /// Parts of a multivaluated data are separated by back-slash + mutable std::string *StrHexaArea; // to avoid allocating useless std::string private: /// \brief 0 for straight entries, FLAG_PIXELDATA for Pixel Data entries - char Flag; - /// \brief Entry status : STATE_NOTLOADED,STATE_UNFOUND, STATE_UNREAD, 0 - char State; + TValueFlag Flag; + /// \brief Entry status:STATE_NOTLOADED,STATE_UNFOUND,STATE_UNREAD,STATE_LOADED + TValueState State; - /// \brief Size threshold above which an element val - /// By default, this upper bound is fixed to 64 bytes. + /// \brief Size threshold above which an element is printed static uint32_t MaxSizePrintEntry; };