]> Creatis software - gdcm.git/blob - src/gdcmDirList.h
change
[gdcm.git] / src / gdcmDirList.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDirList.h,v $
5   Language:  C++
6   Date:      $Date: 2009/02/05 09:03:26 $
7   Version:   $Revision: 1.37 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19 #ifndef _GDCMDIRLIST_H_
20 #define _GDCMDIRLIST_H_
21
22 #include "gdcmBase.h"
23 #include "gdcmDicomDirSerie.h"
24
25 #include <string>
26 #include <vector>
27 #include <iostream>
28
29 namespace GDCM_NAME_SPACE
30 {
31
32 typedef std::vector<std::string> DirListType;
33
34 //-----------------------------------------------------------------------------
35
36 // NOTE: Due to a M$VC6 'feature' we cannot export a std::list in a dll, 
37 // so GDCM_EXPORT keyword was removed for this class only
38 //
39 // We have to supply accessors GetSize(), GetFirst(), GetNext() 
40
41 /**
42  * \brief   List containing the file headers of all the 'gdcm readable' files
43  *          found by exploring (possibly recursively) a root directory. 
44  */
45 class GDCM_EXPORT DirList : public Base
46 {
47 public :
48    DirList(std::string const &dirName, bool recursive, bool all=false);
49    DirList(DicomDirSerie *s);   
50    ~DirList();
51
52    void Print(std::ostream &os = std::cout, std::string const &indent = "" );
53
54    /// Return the name of the directory
55    std::string const &GetDirName() const { return DirName; }
56
57    /// Return the file names
58    DirListType const &GetFilenames() const { return Filenames; }
59    
60     /// Return the number of Files
61    int GetSize() const { return Filenames.size(); }  
62
63    static bool IsDirectory(std::string const &dirName);
64    
65    std::string GetFirst();
66    std::string GetNext();
67    
68 private :
69    int Explore(std::string const &dirName, bool recursive=false, bool all=false);
70    int Explore(DicomDirSerie *s);
71    
72    /// List of file names
73    DirListType Filenames;
74    /// name of the root directory to explore
75    std::string DirName;
76    
77    /// iterator on the SQItems of the current SeqEntry
78    DirListType::iterator ItDirList;  
79    
80 };
81 } // end namespace gdcm
82 //-----------------------------------------------------------------------------
83 #endif