]> Creatis software - gdcm.git/commitdiff
ENH: A few minor cosmetic cleanups, mostly some const correctness on gdcmDict* classe...
authormalaterre <malaterre>
Mon, 18 Oct 2004 02:17:06 +0000 (02:17 +0000)
committermalaterre <malaterre>
Mon, 18 Oct 2004 02:17:06 +0000 (02:17 +0000)
src/gdcmDict.cxx
src/gdcmDict.h
src/gdcmDictEntry.cxx
src/gdcmDictEntry.h
src/gdcmDictSet.cxx
src/gdcmDictSet.h
src/gdcmJpeg.cxx

index bb6bd72eb67de471d3eee997c81c126abf696737..8662d1513c4e2901bb85f18edac83bc0e6a3eeeb 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDict.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/10/12 04:35:45 $
-  Version:   $Revision: 1.45 $
+  Date:      $Date: 2004/10/18 02:17:06 $
+  Version:   $Revision: 1.46 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -23,6 +23,7 @@
 #include <fstream>
 #include <iostream>
 #include <iomanip>
+
 namespace gdcm 
 {
 
@@ -47,15 +48,14 @@ Dict::Dict(std::string const & filename)
    while (!from.eof())
    {
       from >> std::hex;
-      from >> group;          /// MEMORY LEAK in std::istream::operator>>
+      from >> group;
       from >> element;
       from >> vr;
       from >> fourth;
-      from >> std::ws; // used to be eatwhite(from);
-      std::getline(from, name);    /// MEMORY LEAK in std::getline<>
+      from >> std::ws;  //remove white space
+      std::getline(from, name);
 
-      DictEntry * newEntry = new DictEntry(group, element,
-                                                   vr, fourth, name);
+      DictEntry * newEntry = new DictEntry(group, element, vr, fourth, name);
       AddNewEntry(newEntry);
    }
    from.close();
@@ -233,7 +233,7 @@ bool Dict::RemoveEntry (uint16_t group, uint16_t element)
  *            the name MAY CHANGE between two versions !
  * @return  the corresponding dictionnary entry when existing, NULL otherwise
  */
-DictEntry* Dict::GetDictEntryByName(TagName name)
+DictEntry* Dict::GetDictEntryByName(TagName const & name)
 {
    if ( !NameHt.count(name))
    {
@@ -264,9 +264,9 @@ DictEntry* Dict::GetDictEntryByNumber(uint16_t group, uint16_t element)
  * \sa      DictSet::GetPubDictTagNamesByCategory
  * @return  A list of all entries of the public dicom dictionnary.
  */
-std::list<std::string>* Dict::GetDictEntryNames() 
+EntryNamesList* Dict::GetDictEntryNames() 
 {
-   std::list<std::string> *result = new std::list<std::string>;
+   EntryNamesList *result = new EntryNamesList;
    for (TagKeyHT::iterator tag = KeyHt.begin(); tag != KeyHt.end(); ++tag)
    {
       result->push_back( tag->second->GetName() );
@@ -298,9 +298,9 @@ std::list<std::string>* Dict::GetDictEntryNames()
  *          corresponding values are lists of all the dictionnary entries
  *          among that group.
  */
-std::map<std::string, std::list<std::string> > *Dict::GetDictEntryNamesByCategory(void
+EntryNamesByCatMap *Dict::GetDictEntryNamesByCategory(
 {
-   std::map<std::string, std::list<std::string> > *result = new std::map<std::string, std::list<std::string> >;
+   EntryNamesByCatMap *result = new EntryNamesByCatMap;
 
    for (TagKeyHT::iterator tag = KeyHt.begin(); tag != KeyHt.end(); ++tag)
    {
index 6fcfd93a79cad98d69a9c4ba94cadbd91b3a5854..b6152da2f634baf63e0db3b2ce0d557087802d51 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDict.h,v $
   Language:  C++
-  Date:      $Date: 2004/10/12 04:35:45 $
-  Version:   $Revision: 1.19 $
+  Date:      $Date: 2004/10/18 02:17:06 $
+  Version:   $Revision: 1.20 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include <iostream>
 #include <list>
 #include <map>
+
 namespace gdcm 
 {
 
 //-----------------------------------------------------------------------------
 typedef std::map<TagKey, DictEntry*> TagKeyHT;
 typedef std::map<TagName, DictEntry*> TagNameHT;
-
+typedef std::list<std::string>        EntryNamesList;
+typedef std::map<std::string, std::list<std::string> > EntryNamesByCatMap;
 //-----------------------------------------------------------------------------
 /*
  * \defgroup Dict
@@ -46,7 +48,7 @@ typedef std::map<TagName, DictEntry*> TagNameHT;
 class GDCM_EXPORT Dict
 {
 public:
-   Dict(std::string const & FileName);
+   Dict(std::string const & filename);
    ~Dict();
 
 // Print
@@ -55,32 +57,33 @@ public:
    void PrintByName(std::ostream &os = std::cout);
 
 // Entries
-   bool AddNewEntry (DictEntry *NewEntry);
-   bool ReplaceEntry(DictEntry *NewEntry);
+   bool AddNewEntry (DictEntry *newEntry);
+   bool ReplaceEntry(DictEntry *newEntry);
    bool RemoveEntry (TagKey key);
    bool RemoveEntry (uint16_t group, uint16_t element);
    
 // Tag
-   DictEntry *GetDictEntryByName(TagName name);
+   DictEntry *GetDictEntryByName(TagName const & name);
    DictEntry *GetDictEntryByNumber(uint16_t group, uint16_t element);
 
-   std::list<std::string> *GetDictEntryNames();
-   std::map<std::string, std::list<std::string> > *
-        GetDictEntryNamesByCategory();
+   EntryNamesList *GetDictEntryNames();
+   EntryNamesByCatMap *GetDictEntryNamesByCategory();
 
    /// \brief  Returns a ref to the Dicom Dictionary H table (map)
    /// @return the Dicom Dictionary H table
-   TagKeyHT & GetEntriesByKey()  { return KeyHt; }
+   const TagKeyHT & GetEntriesByKey() const { return KeyHt; }
 
    /// \brief  Returns a ref to the Dicom Dictionary H table (map)
    /// @return the Dicom Dictionary H table
-   TagNameHT & GetEntriesByName()  { return NameHt; }
+   const TagNameHT & GetEntriesByName() const { return NameHt; }
  
 private:
    /// ASCII file holding the Dictionnary
    std::string Filename;
+
    /// Access through TagKey (see alternate access with NameHt)
    TagKeyHT  KeyHt;
+
    /// Access through TagName (see alternate access with KeyHt)
    TagNameHT NameHt;
 };
index d3bb9197eb81d9e338701beae23e38e5006c0cf6..8411e2edf27c6fc58650f0d2276edc04f1d71e02 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDictEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/10/12 04:35:45 $
-  Version:   $Revision: 1.26 $
+  Date:      $Date: 2004/10/18 02:17:06 $
+  Version:   $Revision: 1.27 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -36,8 +36,8 @@ namespace gdcm
 */
 
 DictEntry::DictEntry(uint16_t group, uint16_t element,
-                             std::string vr, std::string fourth,
-                             std::string name)
+                     TagName vr, TagName fourth,
+                     TagName name)
 {
    Group   = group;
    Element = element;
@@ -72,7 +72,7 @@ TagKey DictEntry::TranslateToKey(uint16_t group, uint16_t element)
  * \            is unset then overwrite it.
  * @param vr    New V(alue) R(epresentation) to be set.
  */
-void DictEntry::SetVR(std::string const & vr) 
+void DictEntry::SetVR(TagName const & vr) 
 {
    if ( IsVRUnknown() )
    {
index dce045305bf501dd009c1182807a4597af22ed4d..1e11a6ad910a13e95eaaea56d4d8c5cf7583345c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDictEntry.h,v $
   Language:  C++
-  Date:      $Date: 2004/10/12 04:35:45 $
-  Version:   $Revision: 1.18 $
+  Date:      $Date: 2004/10/18 02:17:06 $
+  Version:   $Revision: 1.19 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -39,14 +39,14 @@ class GDCM_EXPORT DictEntry
 {
 public:
    DictEntry(uint16_t group, 
-                 uint16_t element,
-                 std::string vr     = "Unknown",
-                 std::string fourth = "Unknown",
-                 std::string name   = "Unknown");
+             uint16_t element,
+             TagName vr     = "Unknown",
+             TagName fourth = "Unknown",
+             TagName name   = "Unknown");
 
    static TagKey TranslateToKey(uint16_t group, uint16_t element);
 
-   void SetVR(std::string const & vr);
+   void SetVR(TagName const & vr);
 
    /// \brief tells if the V(alue) R(epresentation) is known (?!)
    /// @return 
@@ -63,26 +63,26 @@ public:
    /// \brief  Returns the Dicom Value Representation of the current
    ///         DictEntry
    /// @return the Dicom Value Representation
-   std::string GetVR() { return VR; }
+   const TagName & GetVR() const { return VR; }
  
    /// \brief   sets the key of the current DictEntry
    /// @param k New key to be set.
-   void SetKey(std::string const & k)  { Key = k; }
+   void SetKey(TagName const & k)  { Key = k; }
  
    /// \brief   returns the Fourth field of the current DictEntry
    /// \warning NOT part of the Dicom Standard.
    ///          May be REMOVED an any time. NEVER use it.
    /// @return  The Fourth field
-   std::string GetFourth() { return Fourth; } 
+   const TagName & GetFourth() const { return Fourth; } 
 
    /// \brief  Returns the Dicom Name of the current DictEntry
    ///         e.g. "Patient Name" for Dicom Tag (0x0010, 0x0010) 
    /// @return the Dicom Name
-   std::string GetName() { return Name; } 
+   const TagName & GetName() const { return Name; } 
  
    /// \brief  Gets the key of the current DictEntry
    /// @return the key.
-   std::string GetKey() { return Key; }
+   const TagName & GetKey() const { return Key; }
 
 private:
    /// \todo FIXME 
@@ -102,7 +102,7 @@ private:
    /// \brief Value Representation i.e. some clue about the nature
    ///        of the data represented e.g. "FD" short for
    ///        "Floating Point Double" (see \ref VR)
-   std::string VR;
+   TagName VR;
 
    /**
     * \brief AVOID using the following fourth field at all costs.
@@ -161,10 +161,10 @@ private:
     *  - LLO = Left  Lateral Oblique  
     *  .
     */
-   std::string Fourth; 
+   TagName Fourth; 
 
    /// e.g. "Patient's Name"                    
-   std::string Name;      
+   TagName Name;      
 
    /// Redundant with (group, element) but we add it for efficiency purpose.
    TagKey  Key;
index a18a25faff4cb6b2b0395d29c63fc08a34da83e6..53c1ff3c543c3d042045960e975a541a3eeebc0f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDictSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/10/12 04:35:45 $
-  Version:   $Revision: 1.38 $
+  Date:      $Date: 2004/10/18 02:17:07 $
+  Version:   $Revision: 1.39 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -20,6 +20,7 @@
 #include "gdcmDebug.h"
 #include <fstream>
 #include <stdlib.h>  // For getenv
+
 namespace gdcm 
 {
 
@@ -95,7 +96,7 @@ void DictSet::Print(std::ostream& os)
  * \sa DictSet::GetPubDictTagNamesByCategory
  * @return  A list of all entries of the public dicom dictionnary.
  */
-std::list<std::string> *DictSet::GetPubDictEntryNames() 
+EntryNamesList * DictSet::GetPubDictEntryNames() 
 {
    return GetDefaultPubDict()->GetDictEntryNames();
 }
@@ -126,8 +127,7 @@ std::list<std::string> *DictSet::GetPubDictEntryNames()
  *          corresponding values are lists of all the dictionnary entries
  *          among that group.
  */
-std::map<std::string, std::list<std::string> > *
-   DictSet::GetPubDictEntryNamesByCategory() 
+EntryNamesByCatMap * DictSet::GetPubDictEntryNamesByCategory() 
 {
    return GetDefaultPubDict()->GetDictEntryNamesByCategory();
 }
@@ -142,7 +142,7 @@ std::map<std::string, std::list<std::string> > *
  *          created dictionary.
  */
 Dict *DictSet::LoadDictFromFile(std::string const & fileName, 
-                                        DictKey const & name) 
+                                DictKey const & name) 
 {
    Dict *newDict = new Dict(fileName);
    AppendDict(newDict, name);
@@ -172,11 +172,11 @@ Dict *DictSet::GetDict(DictKey const & dictName)
  *          in no dictionnary
  * @return  virtual entry
  */
-DictEntry *DictSet::NewVirtualDictEntry(uint16_t group,
-                                                uint16_t element,
-                                                std::string vr,
-                                                std::string fourth,
-                                                std::string name)
+DictEntry *DictSet::NewVirtualDictEntry( uint16_t group,
+                                         uint16_t element,
+                                         TagName vr,
+                                         TagName fourth,
+                                         TagName name)
 {
    DictEntry* entry;
    const std::string tag = DictEntry::TranslateToKey(group,element)
index 68130b4fbec8937f52d2d757c60b4f52a6de1c1f..895459d094903057916db82a368bb447deeaa0b3 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDictSet.h,v $
   Language:  C++
-  Date:      $Date: 2004/10/12 04:35:45 $
-  Version:   $Revision: 1.27 $
+  Date:      $Date: 2004/10/18 02:17:07 $
+  Version:   $Revision: 1.28 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -22,9 +22,9 @@
 #include "gdcmDict.h"
 #include <map>
 #include <list>
+
 namespace gdcm 
 {
-
 typedef std::string DictKey;
 typedef std::map<DictKey, Dict*> DictSetHT;
 
@@ -45,12 +45,11 @@ public:
 
    void Print(std::ostream& os);
 
-   std::list<std::string>* GetPubDictEntryNames();
-   std::map<std::string, std::list<std::string> > *
-       GetPubDictEntryNamesByCategory();
+   EntryNamesList * GetPubDictEntryNames();
+   EntryNamesByCatMap * GetPubDictEntryNamesByCategory();
 
    Dict* LoadDictFromFile( std::string const & fileName,
-                               DictKey const & name );
+                           DictKey const & name );
 
    Dict* GetDict( DictKey const & DictName );
 
@@ -62,9 +61,9 @@ public:
    // Dict* GetVirtualDict() { return &VirtualEntry; };
 
    DictEntry* NewVirtualDictEntry(uint16_t group, uint16_t element,
-                                      std::string vr     = "Unknown",
-                                      std::string fourth = "Unknown",
-                                      std::string name   = "Unknown");
+                                  TagName vr     = "Unknown",
+                                  TagName fourth = "Unknown",
+                                  TagName name   = "Unknown");
 
    static std::string BuildDictPath();
 
@@ -74,8 +73,10 @@ protected:
 private:
    /// Hash table of all dictionaries contained in this DictSet
    DictSetHT Dicts;
+
    /// Directory path to dictionaries
    std::string DictPath;
+
    /// H table for the on the fly created DictEntries  
    TagKeyHT VirtualEntry; 
 };
index c13b1860ccda9263ea9ced535ab7eb51aefa1833..00cf4b0af90e46e5e30db4be414fb7283e3805cd 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmJpeg.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/10/15 15:44:42 $
-  Version:   $Revision: 1.26 $
+  Date:      $Date: 2004/10/18 02:17:07 $
+  Version:   $Revision: 1.27 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -538,6 +538,7 @@ bool gdcm_read_JPEG_file ( FILE* fp, void* image_buffer )
        * more than one scanline at a time if that's more convenient.
        */
 
+     //printf( "scanlines: %d\n",cinfo.output_scanline);
       (void) jpeg_read_scanlines(&cinfo, buffer, 1);
       memcpy( pimage, *buffer,rowsize); 
       pimage+=rowsize;