From 2f27193f6cbd42d1143738e40563b4a4bd4a0c8a Mon Sep 17 00:00:00 2001 From: malaterre Date: Mon, 25 Oct 2004 04:47:41 +0000 Subject: [PATCH] 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 sub class shouldn't reuse the keyword (4) --- ChangeLog | 5 +++ Example/PrintDicomDir.cxx | 8 ++--- Example/TestCopyDicom.cxx | 4 +-- Testing/TestCopyDicom.cxx | 4 +-- Testing/TestDicomDir.cxx | 8 ++--- src/gdcmDicomDir.cxx | 12 +++---- src/gdcmDicomDir.h | 18 +++++------ src/gdcmDocument.cxx | 10 +++--- src/gdcmElementSet.h | 33 +++++++++---------- src/gdcmUtil.cxx | 67 +++++++++++++++++---------------------- src/gdcmUtil.h | 18 +++++------ 11 files changed, 90 insertions(+), 97 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0d9168f6..03a03809 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-10-25 Mathieu Malaterre + * 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 * Doc/Dicom2004_Part5.pdf added (thanks to JPR). * Dicts/dicomTS2004.dic, dicomV3VM2004.dic, groupNameAbbreviations2004.dic diff --git a/Example/PrintDicomDir.cxx b/Example/PrintDicomDir.cxx index c3060c92..6a21a08a 100644 --- a/Example/PrintDicomDir.cxx +++ b/Example/PrintDicomDir.cxx @@ -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; diff --git a/Example/TestCopyDicom.cxx b/Example/TestCopyDicom.cxx index cc42d86c..f93ce53e 100644 --- a/Example/TestCopyDicom.cxx +++ b/Example/TestCopyDicom.cxx @@ -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; diff --git a/Testing/TestCopyDicom.cxx b/Testing/TestCopyDicom.cxx index 29588aef..3689353a 100644 --- a/Testing/TestCopyDicom.cxx +++ b/Testing/TestCopyDicom.cxx @@ -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(d) ) diff --git a/Testing/TestDicomDir.cxx b/Testing/TestDicomDir.cxx index e0ca32ab..73710b1e 100644 --- a/Testing/TestDicomDir.cxx +++ b/Testing/TestDicomDir.cxx @@ -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; diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index 68e27d63..5c264bf2 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -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); diff --git a/src/gdcmDicomDir.h b/src/gdcmDicomDir.h index c7605f62..edbc7b4b 100644 --- a/src/gdcmDicomDir.h +++ b/src/gdcmDicomDir.h @@ -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 #include + namespace gdcm { - //----------------------------------------------------------------------------- typedef std::list ListDicomDirPatient; typedef std::vector 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 diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index d6006ab5..550aa731 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -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; diff --git a/src/gdcmElementSet.h b/src/gdcmElementSet.h index c76fefee..c1da9457 100644 --- a/src/gdcmElementSet.h +++ b/src/gdcmElementSet.h @@ -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 @@ -27,10 +27,9 @@ class ValEntry; class BinEntry; class SeqEntry; + namespace gdcm { - - typedef std::map 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 //----------------------------------------------------------------------------- diff --git a/src/gdcmUtil.cxx b/src/gdcmUtil.cxx index 6e6f9f3d..ed2fe33f 100644 --- a/src/gdcmUtil.cxx +++ b/src/gdcmUtil.cxx @@ -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& tokens, - const std::string& delimiters) + std::vector& 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 backslash_pos ? slash_pos : backslash_pos; + if(slash_pos != std::string::npos) + { + return filename.substr(slash_pos + 1); + } + else + { + return filename; + } } } // end namespace gdcm diff --git a/src/gdcmUtil.h b/src/gdcmUtil.h index 3ec7b666..2fb0ab22 100644 --- a/src/gdcmUtil.h +++ b/src/gdcmUtil.h @@ -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& tokens, - const std::string& delimiters = " "); + std::vector& 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 //----------------------------------------------------------------------------- -- 2.48.1