GDCM  2.2.0
gdcmDirectory.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program: GDCM (Grassroots DICOM). A DICOM library
00004 
00005   Copyright (c) 2006-2011 Mathieu Malaterre
00006   All rights reserved.
00007   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
00008 
00009      This software is distributed WITHOUT ANY WARRANTY; without even
00010      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00011      PURPOSE.  See the above copyright notice for more information.
00012 
00013 =========================================================================*/
00014 #ifndef GDCMDIRECTORY_H
00015 #define GDCMDIRECTORY_H
00016 
00017 #include "gdcmTypes.h"
00018 
00019 #include <string>
00020 #include <vector>
00021 #include <iostream>
00022 #include <assert.h>
00023 
00024 namespace gdcm
00025 {
00041 //-----------------------------------------------------------------------------
00042 class GDCM_EXPORT Directory
00043 {
00044   friend std::ostream& operator<<(std::ostream &_os, const Directory &d);
00045 public :
00046   Directory() {}
00047   ~Directory() {}
00048   typedef std::string FilenameType;
00049   typedef std::vector<FilenameType> FilenamesType;
00050 
00052   void Print(std::ostream &os = std::cout) const;
00053 
00055   FilenameType const &GetToplevel() const { return Toplevel; }
00056 
00058   FilenamesType const &GetFilenames() const {
00059     assert( !(Toplevel.empty()) && "Need to call Explore first" );
00060     return Filenames; }
00061 
00063   FilenamesType const &GetDirectories() const { return Directories; }
00064 
00067   unsigned int Load(FilenameType const &name, bool recursive = false) {
00068     Filenames.clear(); // clear previous
00069     Directories.clear(); // clear previous
00070     Toplevel = name;
00071     return Explore( Toplevel, recursive );
00072   }
00073   // \todo later: GLOB
00074   // The glob() function searches for all the pathnames matching pattern according to
00075   // the rules used by the shell (see glob(7)).  No tilde expansion or parameter
00076   // substitution is done; if you want these, use wordexp(3).
00077   // int Glob(...);
00078 
00079 protected:
00081   unsigned int Explore(FilenameType const &name, bool recursive);
00082 
00083 private :
00085   FilenamesType Filenames;
00086   FilenamesType Directories;
00087 
00089   FilenameType Toplevel;
00090 };
00091 //-----------------------------------------------------------------------------
00092 inline std::ostream& operator<<(std::ostream &os, const Directory &d)
00093 {
00094   d.Print( os );
00095   return os;
00096 }
00097 
00098 } // end namespace gdcm
00099 //-----------------------------------------------------------------------------
00100 #endif //GDCMDIRECTORY_H

Generated on Tue Mar 27 2012 13:33:39 for GDCM by doxygen 1.8.0
SourceForge.net Logo