]> Creatis software - gdcm.git/commitdiff
STYLE: ivars should start with a capital letter. Accessors should be const to avoid...
authormalaterre <malaterre>
Mon, 25 Oct 2004 04:47:41 +0000 (04:47 +0000)
committermalaterre <malaterre>
Mon, 25 Oct 2004 04:47:41 +0000 (04:47 +0000)
ChangeLog
Example/PrintDicomDir.cxx
Example/TestCopyDicom.cxx
Testing/TestCopyDicom.cxx
Testing/TestDicomDir.cxx
src/gdcmDicomDir.cxx
src/gdcmDicomDir.h
src/gdcmDocument.cxx
src/gdcmElementSet.h
src/gdcmUtil.cxx
src/gdcmUtil.h

index 0d9168f6aadc8ec2ed06dcbd77c23b269bb388fa..03a0380903485caa26964ec59ce22665646f46b9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-10-25 Mathieu Malaterre  <Mathieu.Malaterre@creatis.insa-lyon.fr>
+  * STYLE: ivars should start with a capital letter. 
+  * Accessors should be const to avoid people starting modifying stuff (since this is a ref). 
+  * remove 'virtual' as Style specify subclasses shouldn't reuse the keyword
+  
 2004-10-22 Eric Boix <Eric.Boix@creatis.insa-lyon.fr>
   * Doc/Dicom2004_Part5.pdf added (thanks to JPR).
   * Dicts/dicomTS2004.dic, dicomV3VM2004.dic, groupNameAbbreviations2004.dic
index c3060c9295d2424fba4370317d7580b2d6350139..6a21a08a9666bd3e502d1f45af27ae1884ef31f7 100644 (file)
@@ -12,10 +12,10 @@ int main(int argc, char* argv[])
 {  
    gdcm::DicomDir *e1;
    
-   gdcm::ListDicomDirPatient::iterator  itPatient;
-   gdcm::ListDicomDirStudy::iterator    itStudy;
-   gdcm::ListDicomDirSerie::iterator    itSerie;
-   gdcm::ListDicomDirImage::iterator    itImage;
+   gdcm::ListDicomDirPatient::const_iterator  itPatient;
+   gdcm::ListDicomDirStudy::const_iterator    itStudy;
+   gdcm::ListDicomDirSerie::const_iterator    itSerie;
+   gdcm::ListDicomDirImage::const_iterator    itImage;
    gdcm::TSKey v;
     
    std::string file; 
index cc42d86c58ed9c68fa7a3aabd36549e79c9d4187..f93ce53ec1068012d6f831b4a7056e4f47d676b0 100644 (file)
@@ -70,7 +70,7 @@ int main(int argc, char* argv[])
    
       gdcm::File *copy = new gdcm::File( output );
 
-      gdcm::TagDocEntryHT & Ht = original->GetHeader()->GetEntry();
+      const gdcm::TagDocEntryHT & Ht = original->GetHeader()->GetTagHT();
 
       size_t dataSize = original->GetImageDataSize();
       uint8_t* imageData = original->GetImageData();
@@ -84,7 +84,7 @@ int main(int argc, char* argv[])
 
       gdcm::DocEntry* d;
 
-      for (gdcm::TagDocEntryHT::iterator tag = Ht.begin(); tag != Ht.end(); ++tag)
+      for (gdcm::TagDocEntryHT::const_iterator tag = Ht.begin(); tag != Ht.end(); ++tag)
       {
          d = tag->second;
          d->Print(); std::cout << std::endl;
index 29588aefc33385a86d6ef45761b2b3a8e88b7319..3689353aa348185eae3cc2f8269ff993caec710e 100644 (file)
@@ -69,7 +69,7 @@ int TestCopyDicom(int , char* [])
       gdcm::File *original = new gdcm::File( filename );
       gdcm::File *copy = new gdcm::File( output );
 
-      gdcm::TagDocEntryHT & Ht = original->GetHeader()->GetEntry();
+      const gdcm::TagDocEntryHT & Ht = original->GetHeader()->GetTagHT();
 
       size_t dataSize = original->GetImageDataSize();
       uint8_t* imageData = original->GetImageData();
@@ -83,7 +83,7 @@ int TestCopyDicom(int , char* [])
 
       gdcm::DocEntry* d;
 
-      for (gdcm::TagDocEntryHT::iterator tag = Ht.begin(); tag != Ht.end(); ++tag)
+      for (gdcm::TagDocEntryHT::const_iterator tag = Ht.begin(); tag != Ht.end(); ++tag)
       {
          d = tag->second;
          if ( gdcm::BinEntry* b = dynamic_cast<gdcm::BinEntry*>(d) )
index e0ca32abd003007b3ff8d3b32cd37f6d7399a4ff..73710b1e60496013554d2d3afe2cabef0af756d9 100644 (file)
@@ -9,10 +9,10 @@ int TestDicomDir(int argc, char* argv[])
 {  
    gdcm::DicomDir *e1;
    
-   gdcm::ListDicomDirPatient::iterator  itPatient;
-   gdcm::ListDicomDirStudy::iterator    itStudy;
-   gdcm::ListDicomDirSerie::iterator    itSerie;
-   gdcm::ListDicomDirImage::iterator    itImage;
+   gdcm::ListDicomDirPatient::const_iterator  itPatient;
+   gdcm::ListDicomDirStudy::const_iterator    itStudy;
+   gdcm::ListDicomDirSerie::const_iterator    itSerie;
+   gdcm::ListDicomDirImage::const_iterator    itImage;
    gdcm::TSKey v;
     
    std::string file; 
index 68e27d63cac75e1633cefb42811892028aadbb16..5c264bf26b06875a1973b1948a5b7c49fa2941c8 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/10/25 04:08:19 $
-  Version:   $Revision: 1.75 $
+  Date:      $Date: 2004/10/25 04:47:43 $
+  Version:   $Revision: 1.76 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -534,7 +534,7 @@ DicomDirPatient * DicomDir::NewPatient()
  *          GDCM_DICOMDIR_STUDY, GDCM_DICOMDIR_SERIE ...)
  * @param   header Header of the current file
  */
-void DicomDir::SetElement(std::string &path, DicomDirType type,
+void DicomDir::SetElement(std::string const & path, DicomDirType type,
                           Document *header)
 {
    ListDicomDirElem elemList; //FIXME this is going to be a by copy operation
@@ -912,7 +912,7 @@ void DicomDir::AddDicomDirSerieToEnd(SQItem *s)
  * @param   path path of the root directory
  * @param   list chained list of Headers
  */
-void DicomDir::SetElements(std::string &path, VectDocument &list)
+void DicomDir::SetElements(std::string const & path, VectDocument const &list)
 {
    std::string patPrevName         = "", patPrevID  = "";
    std::string studPrevInstanceUID = "", studPrevID = "";
@@ -922,8 +922,8 @@ void DicomDir::SetElements(std::string &path, VectDocument &list)
    std::string studCurInstanceUID, studCurID;
    std::string serCurInstanceUID,  serCurID;
 
-   for( VectDocument::iterator it = list.begin();
-                              it != list.end(); ++it )
+   for( VectDocument::const_iterator it = list.begin();
+                                     it != list.end(); ++it )
    {
       // get the current file characteristics
       patCurName         = (*it)->GetEntryByNumber(0x0010,0x0010); 
index c7605f6211a53edc74407af990e2dffd3ea10400..edbc7b4bd0756d6393b0f6a5f9649251e840741a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.h,v $
   Language:  C++
-  Date:      $Date: 2004/10/12 04:35:44 $
-  Version:   $Revision: 1.34 $
+  Date:      $Date: 2004/10/25 04:47:43 $
+  Version:   $Revision: 1.35 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -27,9 +27,9 @@
 
 #include <list>
 #include <vector>
+
 namespace gdcm 
 {
-
 //-----------------------------------------------------------------------------
 typedef std::list<DicomDirPatient*>   ListDicomDirPatient;
 typedef std::vector<Document*>  VectDocument;
@@ -45,14 +45,14 @@ typedef GDCM_EXPORT void(Method)(void* = NULL);
 class GDCM_EXPORT DicomDir: public Document
 {
 public:
-   DicomDir( std::string const & fileName, bool parseDir = false );
+   DicomDir( std::string const & filename, bool parseDir = false );
    DicomDir(); 
                    
    ~DicomDir();
 
    /// \brief   canonical Printer 
    /// \sa    SetPrintLevel
-   virtual void Print(std::ostream &os = std::cout);
+   void Print(std::ostream &os = std::cout);
 
    /// Informations contained in the parser
    virtual bool IsReadable();
@@ -61,7 +61,7 @@ public:
    DicomDirMeta* GetDicomDirMeta() { return MetaElems; };
 
    /// Returns the PATIENT chained List for this DICOMDIR.    
-   ListDicomDirPatient &GetDicomDirPatients() { return Patients; };
+   ListDicomDirPatient const & GetDicomDirPatients() const { return Patients; };
 
    /// Parsing
    void ParseDirectory();
@@ -115,11 +115,11 @@ private:
    void AddDicomDirSerieToEnd  (SQItem* s);
    void AddDicomDirImageToEnd  (SQItem* s);
 
-   void SetElements(std::string &path, VectDocument &list);
-   void SetElement (std::string &path,DicomDirType type,
+   void SetElements(std::string const & path, VectDocument const &list);
+   void SetElement (std::string const & path, DicomDirType type,
                     Document* header);
 
-   static bool HeaderLessThan(Document* header1,Document* header2);
+   static bool HeaderLessThan(Document* header1, Document* header2);
    
 // Variables
 
index d6006ab5e2e4c948772f45b354ddebbe75825c92..550aa731d16a7d903272ca104f8ae3d962a7e37c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/10/25 03:35:20 $
-  Version:   $Revision: 1.113 $
+  Date:      $Date: 2004/10/25 04:47:43 $
+  Version:   $Revision: 1.114 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -2932,9 +2932,9 @@ void Document::BuildFlatHashTableRecurse( TagDocEntryHT& builtHT,
 { 
    if (ElementSet* elementSet = dynamic_cast< ElementSet* > ( set ) )
    {
-      TagDocEntryHT* currentHT = elementSet->GetTagHT();
-      for( TagDocEntryHT::const_iterator i  = currentHT->begin();
-                                         i != currentHT->end();
+      TagDocEntryHT const & currentHT = elementSet->GetTagHT();
+      for( TagDocEntryHT::const_iterator i  = currentHT.begin();
+                                         i != currentHT.end();
                                        ++i)
       {
          DocEntry* entry = i->second;
index c76fefee9fe956a9682321c0bc924c96b1f8affd..c1da9457d10441695996b84172e2d9ab9b02dccf 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmElementSet.h,v $
   Language:  C++
-  Date:      $Date: 2004/10/22 03:05:41 $
-  Version:   $Revision: 1.20 $
+  Date:      $Date: 2004/10/25 04:47:43 $
+  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
 class ValEntry;
 class BinEntry;
 class SeqEntry;
+
 namespace gdcm 
 {
-
-
 typedef std::map<TagKey, DocEntry *> TagDocEntryHT;
 
 //-----------------------------------------------------------------------------
@@ -40,30 +39,28 @@ class GDCM_EXPORT ElementSet : public DocEntrySet
 public:
    ElementSet(int);
    ~ElementSet();
-   virtual bool AddEntry(DocEntry *Entry);
+
+   bool AddEntry(DocEntry *Entry);
    bool RemoveEntry(DocEntry *EntryToRemove);
    bool RemoveEntryNoDestroy(DocEntry *EntryToRemove);
    
-   virtual void Print(std::ostream &os = std::cout); 
-   virtual void Write(std::ofstream *fp, FileType filetype); 
-
+   void Print(std::ostream &os = std::cout); 
+   void Write(std::ofstream *fp, FileType filetype); 
+   
    /// Accessor to \ref TagHT
-   // Do not expose this to user (public API) !
-   // I re-add it temporaryly JPRx
-   TagDocEntryHT &GetEntry() { return TagHT; };
-
+   // Do not expose this to user (public API) ! 
+   // A test is using it thus put it in public (matt)
+   TagDocEntryHT const & GetTagHT() const { return TagHT; };
 
 protected:
+    
+private:
 // Variables
    /// Hash Table (map), to provide fast access
    TagDocEntryHT TagHT; 
-     
-private:
-   /// Just for following ::GetTagHT()
    friend class Document;
-
-   /// Accessor to \ref TagHT
-   TagDocEntryHT* GetTagHT() { return &TagHT; };
+   friend class DicomDir; //For accessing private TagHT
 };
 } // end namespace gdcm
 //-----------------------------------------------------------------------------
index 6e6f9f3df4d707273375048b852b6f89018abd58..ed2fe33f7578197ebf5c60a28dd7f6b018f06183 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmUtil.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/10/12 04:35:48 $
-  Version:   $Revision: 1.54 $
+  Date:      $Date: 2004/10/25 04:47:43 $
+  Version:   $Revision: 1.55 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -54,8 +54,8 @@ std::string Util::Format(const char* format, ...)
  * \brief Because not available in C++ (?)
  */
 void Util::Tokenize (const std::string& str,
-               std::vector<std::string>& tokens,
-               const std::string& delimiters)
+                     std::vector<std::string>& tokens,
+                     const std::string& delimiters)
 {
    std::string::size_type lastPos = str.find_first_not_of(delimiters,0);
    std::string::size_type pos     = str.find_first_of    (delimiters,lastPos);
@@ -74,7 +74,7 @@ void Util::Tokenize (const std::string& str,
  */
  
 int Util::CountSubstring (const std::string& str,
-                    const std::string& subStr)
+                          const std::string& subStr)
 {
    int count = 0;   // counts how many times it appears
    unsigned int x = 0;       // The index position in the string
@@ -99,7 +99,7 @@ int Util::CountSubstring (const std::string& str,
  *         to avoid corrupting the terminal of invocation when printing)
  * @param s string to remove non printable characters from
  */
-std::string Util::CreateCleanString(std::string s)
+std::string Util::CreateCleanString(std::string const & s)
 {
    std::string str = s;
 
@@ -137,9 +137,9 @@ void Util::NormalizePath(std::string &name)
    const std::string SEPARATOR = "/";
    int size = name.size();
 
-   if((name[size-1]!=SEPARATOR_X)&&(name[size-1]!=SEPARATOR_WIN))
+   if( name[size-1] != SEPARATOR_X && name[size-1] != SEPARATOR_WIN )
    {
-      name+=SEPARATOR;
+      name += SEPARATOR;
    }
 }
 
@@ -148,20 +148,21 @@ void Util::NormalizePath(std::string &name)
  * \brief   Get the (directory) path from a full path file name
  * @param   fullName file/directory name to extract Path from
  */
-std::string Util::GetPath(std::string &fullName)
+std::string Util::GetPath(std::string const & fullName)
 {
-   int pos1 = fullName.rfind("/");
-   int pos2 = fullName.rfind("\\");
+   std::string res = fullName;
+   int pos1 = res.rfind("/");
+   int pos2 = res.rfind("\\");
    if( pos1 > pos2)
    {
-      fullName.resize(pos1);
+      res.resize(pos1);
    }
    else
    {
-      fullName.resize(pos2);
+      res.resize(pos2);
    }
 
-   return fullName;
+   return res;
 }
 
 /**
@@ -169,31 +170,21 @@ std::string Util::GetPath(std::string &fullName)
  * \brief   Get the (last) name of a full path file name
  * @param   fullName file/directory name to extract end name from
  */
-std::string Util::GetName(std::string &fullName)
+std::string Util::GetName(std::string const & fullName)
 {   
-   int fin = fullName.length()-1;
-   char a =fullName.c_str()[fin];
-   if (a == '/' || a == '\\')
-   {
-      fin--;
-   }
-   int deb = 0;
-   for (int i=fin;i!=0;i--)
-   {
-      if (fullName.c_str()[i] == '/' || fullName.c_str()[i] == '\\')
-      {
-         break;
-      }
-      deb = i;
-   }
-
-   std::string lastName;
-   for (int j=deb;j<fin+1;j++)
-   {
-      lastName=lastName+fullName.c_str()[j];
-   }
-
-  return lastName;
+  std::string filename = fullName;
+
+  std::string::size_type slash_pos = filename.rfind("/");
+  std::string::size_type backslash_pos = filename.rfind("\\");
+  slash_pos = slash_pos > backslash_pos ? slash_pos : backslash_pos;
+  if(slash_pos != std::string::npos)
+    {
+    return filename.substr(slash_pos + 1);
+    }
+  else
+    {
+    return filename;
+    }
 } 
 
 } // end namespace gdcm
index 3ec7b666d11ff4dbba58c53fd82fca55e97f1305..2fb0ab22f192fad3adbc69cd4c9b903916dea2bc 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmUtil.h,v $
   Language:  C++
-  Date:      $Date: 2004/10/12 04:35:48 $
-  Version:   $Revision: 1.36 $
+  Date:      $Date: 2004/10/25 04:47:43 $
+  Version:   $Revision: 1.37 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -27,7 +27,7 @@ namespace gdcm
 {
 /**
  * \defgroup Globals Utility functions
- * \brief    Here are some utility functions, belonging to NO class,
+ * \brief    Here are some utility functions, belonging to the Util class,
  *           dealing with strings, file names... that can be called
  *           from anywhere by whomsoever they can help.
  */
@@ -39,15 +39,15 @@ class GDCM_EXPORT Util
 public:
    static std::string Format(const char* format, ...);
    static void        Tokenize (const std::string& str,
-                         std::vector<std::string>& tokens,
-                         const std::string& delimiters = " ");
+                                std::vector<std::string>& tokens,
+                                const std::string& delimiters = " ");
    static int         CountSubstring (const std::string& str,
-                               const std::string& subStr);       
+                                      const std::string& subStr);       
 
-   static std::string CreateCleanString(std::string s);
+   static std::string CreateCleanString(std::string const & s);
    static void        NormalizePath(std::string &name);
-   static std::string GetPath(std::string &fullName);
-   static std::string GetName(std::string &fullName);
+   static std::string GetPath(std::string const &fullName);
+   static std::string GetName(std::string const &fullName);
 };
 } // end namespace gdcm
 //-----------------------------------------------------------------------------