]> Creatis software - gdcm.git/blob - src/gdcmDirList.h
In order to allow to use current version (1.3) of gdcm *and* ITK (that includes
[gdcm.git] / src / gdcmDirList.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDirList.h,v $
5   Language:  C++
6   Date:      $Date: 2007/05/23 14:18:09 $
7   Version:   $Revision: 1.33 $
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
24 #include <string>
25 #include <vector>
26 #include <iostream>
27
28 namespace GDCM_NAME_SPACE
29 {
30
31 typedef std::vector<std::string> DirListType;
32
33 //-----------------------------------------------------------------------------
34
35 // NOTE: Due to a M$VC6 'feature' we cannot export a std::list in a dll, 
36 // so GDCM_EXPORT keyword was removed for this class only
37
38 /**
39  * \brief   List containing the file headers of all the 'gdcm readable' files
40  *          found by exploring (possibly recursively) a root directory. 
41  */
42 class GDCM_EXPORT DirList : public Base
43 {
44 public :
45    DirList(std::string const &dirName, bool recursive);
46    ~DirList();
47
48    void Print(std::ostream &os = std::cout, std::string const &indent = "" );
49
50    /// Return the name of the directory
51    std::string const &GetDirName() const { return DirName; }
52
53    /// Return the file names
54    DirListType const &GetFilenames() const { return Filenames; }
55    
56     /// Return the number of Files
57    int GetSize() const { return Filenames.size(); }  
58
59    static bool IsDirectory(std::string const &dirName);
60    
61    std::string GetFirst();
62    std::string GetNext();
63    
64 private :
65    int Explore(std::string const &dirName, bool recursive=false);
66
67    /// List of file names
68    DirListType Filenames;
69    /// name of the root directory to explore
70    std::string DirName;
71    
72    /// iterator on the SQItems of the current SeqEntry
73    DirListType::iterator ItDirList;  
74    
75 };
76 } // end namespace gdcm
77 //-----------------------------------------------------------------------------
78 #endif