ATLAS Offline Software
Loading...
Searching...
No Matches
ScanDir.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8#ifndef SAMPLE_HANDLER__SCAN_DIR_H
9#define SAMPLE_HANDLER__SCAN_DIR_H
10
11
13
15#include <map>
16#include <vector>
17
18namespace SH
19{
36
37 struct ScanDir
38 {
39 //
40 // public interface
41 //
42
48 public:
49 ScanDir ();
50
51
61 public:
62 const ScanDir& scan (SampleHandler& sh, const std::string& dir) const;
63
64
74 public:
75 const ScanDir& scanEOS (SampleHandler& sh, const std::string& eosDir) const;
76
77
79 public:
80 const ScanDir& scan (SampleHandler& sh, DiskList& list) const;
81
82
89 public:
90 ScanDir& sampleDepth (int val_sampleDepth);
91
99 public:
100 ScanDir& absSampleDepth (int val_absSampleDepth);
101
104 public:
105 ScanDir& sampleName (const std::string& val_sampleName);
106
108 public:
109 ScanDir& minDepth (std::size_t val_minDepth);
110
112 public:
113 ScanDir& maxDepth (std::size_t val_maxDepth);
114
117 public:
118 ScanDir& filePattern (const std::string& val_filePattern);
119
122 public:
123 ScanDir& fileRegex (const std::string& val_fileRegex);
124
127 public:
128 ScanDir& directoryPattern (const std::string& val_directoryPattern);
129
132 public:
133 ScanDir& directoryRegex (const std::string& val_directoryRegex);
134
136 public:
137 ScanDir& samplePattern (const std::string& val_samplePattern);
138
141 public:
142 ScanDir& samplePostfix (const std::string& val_samplePostfix);
143
145 public:
146 ScanDir& sampleRename (const std::string& pattern, const std::string& name);
147
151 public:
152 ScanDir& extraNameComponent (int val_relSampleDepth);
153
154
155
156 //
157 // private interface
158 //
159
162 private:
164
168 private:
170
172 private:
173 std::string m_sampleName;
174
176 private:
177 std::size_t m_minDepth;
178
180 private:
181 std::size_t m_maxDepth;
182
185 private:
186 std::regex m_filePattern;
187
190 private:
192
195 private:
196 std::regex m_samplePattern;
197
200 private:
201 std::regex m_samplePostfix;
202
205 private:
207
209 private:
210 typedef std::vector<std::pair<std::regex,std::string> >::const_iterator SampleRenameIter;
211 std::vector<std::pair<std::regex,std::string> > m_sampleRename;
212
214 private:
216
217
224 private:
225 void recurse (std::map<std::string,SamplePtr>& samples, DiskList& list,
226 const std::vector<std::string>& hierarchy) const;
227
228
235 private:
236 void addSampleFile (std::map<std::string,SamplePtr>& samples,
237 const std::vector<std::string>& hierarchy,
238 const std::string& path) const;
239
240
247 private:
248 std::string
249 findPathComponent (const std::vector<std::string>& hierarchy,
250 int absSampleDepth,
251 int relSampleDepth) const;
252 };
253}
254
255#endif
an interface for listing directory contents, locally or on a file server
Definition DiskList.h:32
A class that manages a list of Sample objects.
This module provides a lot of global definitions, forward declarations and includes that are used by ...
Definition PrunDriver.h:15
std::regex m_directoryPattern
the value set by directoryPattern, converted to a regular expression
Definition ScanDir.h:191
ScanDir & sampleName(const std::string &val_sampleName)
a single sample name into which all found files should be placed.
Definition ScanDir.cxx:67
std::string m_sampleName
the value set by sampleName
Definition ScanDir.h:173
ScanDir & samplePattern(const std::string &val_samplePattern)
the pattern for samples to be accepted
Definition ScanDir.cxx:130
ScanDir & directoryPattern(const std::string &val_directoryPattern)
the pattern for directories to be visited
Definition ScanDir.cxx:112
const ScanDir & scan(SampleHandler &sh, const std::string &dir) const
scan the given directory and put the created samples into the sample handler
Definition ScanDir.cxx:168
std::vector< std::pair< std::regex, std::string > >::const_iterator SampleRenameIter
the list of entries from sampleRename
Definition ScanDir.h:210
ScanDir & sampleDepth(int val_sampleDepth)
the index of the file hierarchy at which we gather the sample name.
Definition ScanDir.cxx:47
bool m_samplePostfixEmpty
whether samplePostfix has been set to the empty string
Definition ScanDir.h:206
std::regex m_filePattern
the value set by filePattern, converted to a regular expression
Definition ScanDir.h:186
ScanDir & maxDepth(std::size_t val_maxDepth)
the maximum depth for files to make it into the sample
Definition ScanDir.cxx:85
std::string findPathComponent(const std::vector< std::string > &hierarchy, int absSampleDepth, int relSampleDepth) const
find the path component at the given depth
Definition ScanDir.cxx:329
ScanDir & fileRegex(const std::string &val_fileRegex)
the regular expression for files to be accepted
Definition ScanDir.cxx:103
int m_relSampleDepth
if this is negative it is the depth at which we take the sample name, counting from the end
Definition ScanDir.h:163
int m_extraNameComponent
the depth set with extraNameComponent, or 0 otherwise
Definition ScanDir.h:215
ScanDir & directoryRegex(const std::string &val_directoryRegex)
the regular expression for directories to be visited
Definition ScanDir.cxx:121
std::vector< std::pair< std::regex, std::string > > m_sampleRename
Definition ScanDir.h:211
ScanDir & samplePostfix(const std::string &val_samplePostfix)
the pattern for the postfix to be stripped from the sampleName
Definition ScanDir.cxx:139
int m_absSampleDepth
if m_relSampleDepth is not negative, it is the depth at which we take the sample name,...
Definition ScanDir.h:169
ScanDir & minDepth(std::size_t val_minDepth)
the minimum depth for files to make it into the sample
Definition ScanDir.cxx:76
ScanDir & absSampleDepth(int val_absSampleDepth)
the index of the file hierarchy at which we gather the sample name.
Definition ScanDir.cxx:57
std::size_t m_maxDepth
the value set by maxDepth
Definition ScanDir.h:181
std::regex m_samplePattern
the value set by samplePattern, converted to a regular expression
Definition ScanDir.h:196
const ScanDir & scanEOS(SampleHandler &sh, const std::string &eosDir) const
scan the given directory in EOS and put the created samples into the sample handler
Definition ScanDir.cxx:178
ScanDir()
standard constructor
Definition ScanDir.cxx:33
ScanDir & extraNameComponent(int val_relSampleDepth)
attach an extra name component to the sample based on a second component of the path
Definition ScanDir.cxx:158
ScanDir & sampleRename(const std::string &pattern, const std::string &name)
rename any sample matching pattern to name
Definition ScanDir.cxx:149
void recurse(std::map< std::string, SamplePtr > &samples, DiskList &list, const std::vector< std::string > &hierarchy) const
perform the recursive scanning of the directory tree
Definition ScanDir.cxx:210
std::size_t m_minDepth
the value set by minDepth
Definition ScanDir.h:177
void addSampleFile(std::map< std::string, SamplePtr > &samples, const std::vector< std::string > &hierarchy, const std::string &path) const
add the given file to the sample based on the hierarchy, creating the sample if necessary
Definition ScanDir.cxx:255
std::regex m_samplePostfix
the value set by samplePostfix, converted to a regular expression
Definition ScanDir.h:201
ScanDir & filePattern(const std::string &val_filePattern)
the pattern for files to be accepted
Definition ScanDir.cxx:94