00001 #ifndef SAMPLE_HANDLER__SCAN_DIR_H
00002 #define SAMPLE_HANDLER__SCAN_DIR_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <SampleHandler/Global.h>
00016
00017 #include <RootCoreUtils/StringUtil.h>
00018 #include <map>
00019 #include <vector>
00020
00021 namespace SH
00022 {
00039
00040 struct ScanDir
00041 {
00042
00043
00044
00045
00051 public:
00052 ScanDir ();
00053
00054
00064 public:
00065 const ScanDir& scan (SampleHandler& sh, const std::string& dir) const;
00066
00067
00077 public:
00078 const ScanDir& scanEOS (SampleHandler& sh, const std::string& eosDir) const;
00079
00080
00082 public:
00083 const ScanDir& scan (SampleHandler& sh, DiskList& list) const;
00084
00085
00092 public:
00093 ScanDir& sampleDepth (int val_sampleDepth);
00094
00102 public:
00103 ScanDir& absSampleDepth (int val_absSampleDepth);
00104
00107 public:
00108 ScanDir& sampleName (const std::string& val_sampleName);
00109
00111 public:
00112 ScanDir& minDepth (std::size_t val_minDepth);
00113
00115 public:
00116 ScanDir& maxDepth (std::size_t val_maxDepth);
00117
00120 public:
00121 ScanDir& filePattern (const std::string& val_filePattern);
00122
00125 public:
00126 ScanDir& fileRegex (const std::string& val_fileRegex);
00127
00129 public:
00130 ScanDir& samplePattern (const std::string& val_samplePattern);
00131
00134 public:
00135 ScanDir& samplePostfix (const std::string& val_samplePostfix);
00136
00138 public:
00139 ScanDir& sampleRename (const std::string& pattern, const std::string& name);
00140
00144 public:
00145 ScanDir& extraNameComponent (int val_relSampleDepth);
00146
00147
00148
00149
00150
00151
00152
00155 private:
00156 int m_relSampleDepth;
00157
00161 private:
00162 int m_absSampleDepth;
00163
00165 private:
00166 std::string m_sampleName;
00167
00169 private:
00170 std::size_t m_minDepth;
00171
00173 private:
00174 std::size_t m_maxDepth;
00175
00178 private:
00179 boost::regex m_filePattern;
00180
00183 private:
00184 boost::regex m_samplePattern;
00185
00188 private:
00189 boost::regex m_samplePostfix;
00190
00193 private:
00194 bool m_samplePostfixEmpty;
00195
00197 private:
00198 typedef std::vector<std::pair<boost::regex,std::string> >::const_iterator SampleRenameIter;
00199 std::vector<std::pair<boost::regex,std::string> > m_sampleRename;
00200
00202 private:
00203 int m_extraNameComponent;
00204
00205
00212 private:
00213 void recurse (std::map<std::string,SamplePtr>& samples, DiskList& list,
00214 const std::vector<std::string>& hierarchy) const;
00215
00216
00223 private:
00224 void addSampleFile (std::map<std::string,SamplePtr>& samples,
00225 const std::vector<std::string>& hierarchy,
00226 const std::string& path) const;
00227
00228
00235 private:
00236 std::string
00237 findPathComponent (const std::vector<std::string>& hierarchy,
00238 int absSampleDepth,
00239 int relSampleDepth) const;
00240 };
00241 }
00242
00243 #endif