+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
{
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;
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();
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;
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();
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) )
{
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;
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
* 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
* @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 = "";
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);
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
#include <list>
#include <vector>
+
namespace gdcm
{
-
//-----------------------------------------------------------------------------
typedef std::list<DicomDirPatient*> ListDicomDirPatient;
typedef std::vector<Document*> VectDocument;
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();
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();
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
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
{
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;
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;
//-----------------------------------------------------------------------------
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
//-----------------------------------------------------------------------------
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
* \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);
*/
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
* 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;
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;
}
}
* \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;
}
/**
* \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
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
{
/**
* \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.
*/
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
//-----------------------------------------------------------------------------