![]() |
ATLAS Offline Software
|
the class used for scanning local directories and file servers for samples More...
#include <ScanDir.h>
Public Member Functions | |
| ScanDir () | |
| standard constructor | |
| const ScanDir & | scan (SampleHandler &sh, const std::string &dir) const |
| scan the given directory and put the created samples into the sample handler | |
| 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 | |
| const ScanDir & | scan (SampleHandler &sh, DiskList &list) const |
| scan the given directory and put the created samples into the sample handler | |
| ScanDir & | sampleDepth (int val_sampleDepth) |
| the index of the file hierarchy at which we gather the sample name. | |
| ScanDir & | absSampleDepth (int val_absSampleDepth) |
| the index of the file hierarchy at which we gather the sample name. | |
| ScanDir & | sampleName (const std::string &val_sampleName) |
| a single sample name into which all found files should be placed. | |
| ScanDir & | minDepth (std::size_t val_minDepth) |
| the minimum depth for files to make it into the sample | |
| ScanDir & | maxDepth (std::size_t val_maxDepth) |
| the maximum depth for files to make it into the sample | |
| ScanDir & | filePattern (const std::string &val_filePattern) |
| the pattern for files to be accepted | |
| ScanDir & | fileRegex (const std::string &val_fileRegex) |
| the regular expression for files to be accepted | |
| ScanDir & | directoryPattern (const std::string &val_directoryPattern) |
| the pattern for directories to be visited | |
| ScanDir & | directoryRegex (const std::string &val_directoryRegex) |
| the regular expression for directories to be visited | |
| ScanDir & | samplePattern (const std::string &val_samplePattern) |
| the pattern for samples to be accepted | |
| ScanDir & | samplePostfix (const std::string &val_samplePostfix) |
| the pattern for the postfix to be stripped from the sampleName | |
| ScanDir & | sampleRename (const std::string &pattern, const std::string &name) |
| rename any sample matching pattern to name | |
| ScanDir & | extraNameComponent (int val_relSampleDepth) |
| attach an extra name component to the sample based on a second component of the path | |
Private Types | |
| typedef std::vector< std::pair< std::regex, std::string > >::const_iterator | SampleRenameIter |
| the list of entries from sampleRename | |
Private Member Functions | |
| 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 | |
| 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 | |
| std::string | findPathComponent (const std::vector< std::string > &hierarchy, int absSampleDepth, int relSampleDepth) const |
| find the path component at the given depth | |
Private Attributes | |
| int | m_relSampleDepth |
| if this is negative it is the depth at which we take the sample name, counting from the end | |
| int | m_absSampleDepth |
| if m_relSampleDepth is not negative, it is the depth at which we take the sample name, counting from the first directory scanned | |
| std::string | m_sampleName |
| the value set by sampleName | |
| std::size_t | m_minDepth |
| the value set by minDepth | |
| std::size_t | m_maxDepth |
| the value set by maxDepth | |
| std::regex | m_filePattern |
| the value set by filePattern, converted to a regular expression | |
| std::regex | m_directoryPattern |
| the value set by directoryPattern, converted to a regular expression | |
| std::regex | m_samplePattern |
| the value set by samplePattern, converted to a regular expression | |
| std::regex | m_samplePostfix |
| the value set by samplePostfix, converted to a regular expression | |
| bool | m_samplePostfixEmpty |
| whether samplePostfix has been set to the empty string | |
| std::vector< std::pair< std::regex, std::string > > | m_sampleRename |
| int | m_extraNameComponent |
| the depth set with extraNameComponent, or 0 otherwise | |
the class used for scanning local directories and file servers for samples
Originally these was a series of stand-alone function calls, but people kept asking for more and more options, making it unwieldy to call and to maintain. Instead we now have a single class containing all the possible parameters, which makes it easier to configure and extend.
The member functions all return *this, so that usage like this is possible:
|
private |
the list of entries from sampleRename
| SH::ScanDir::ScanDir | ( | ) |
standard constructor
Definition at line 32 of file ScanDir.cxx.
| ScanDir & SH::ScanDir::absSampleDepth | ( | int | val_absSampleDepth | ) |
the index of the file hierarchy at which we gather the sample name.
this differs from sampleDepth in that negative numbers count up in the directory hierarchy from the top of where we scan, while sampleDepth starts counting from the back if the number is negative.
Definition at line 56 of file ScanDir.cxx.
|
private |
add the given file to the sample based on the hierarchy, creating the sample if necessary
Definition at line 254 of file ScanDir.cxx.
| ScanDir & SH::ScanDir::directoryPattern | ( | const std::string & | val_directoryPattern | ) |
the pattern for directories to be visited
Definition at line 111 of file ScanDir.cxx.
| ScanDir & SH::ScanDir::directoryRegex | ( | const std::string & | val_directoryRegex | ) |
the regular expression for directories to be visited
Definition at line 120 of file ScanDir.cxx.
| ScanDir & SH::ScanDir::extraNameComponent | ( | int | val_relSampleDepth | ) |
attach an extra name component to the sample based on a second component of the path
Definition at line 157 of file ScanDir.cxx.
| ScanDir & SH::ScanDir::filePattern | ( | const std::string & | val_filePattern | ) |
the pattern for files to be accepted
Definition at line 93 of file ScanDir.cxx.
| ScanDir & SH::ScanDir::fileRegex | ( | const std::string & | val_fileRegex | ) |
the regular expression for files to be accepted
Definition at line 102 of file ScanDir.cxx.
|
private |
find the path component at the given depth
Definition at line 328 of file ScanDir.cxx.
| ScanDir & SH::ScanDir::maxDepth | ( | std::size_t | val_maxDepth | ) |
the maximum depth for files to make it into the sample
Definition at line 84 of file ScanDir.cxx.
| ScanDir & SH::ScanDir::minDepth | ( | std::size_t | val_minDepth | ) |
the minimum depth for files to make it into the sample
Definition at line 75 of file ScanDir.cxx.
|
private |
perform the recursive scanning of the directory tree
Definition at line 209 of file ScanDir.cxx.
| ScanDir & SH::ScanDir::sampleDepth | ( | int | val_sampleDepth | ) |
the index of the file hierarchy at which we gather the sample name.
this is positive when it starts counting from the top, and negative when it starts from the back, i.e. -1 uses the file name, 0 denotes the directory inside the top level directory
Definition at line 46 of file ScanDir.cxx.
| ScanDir & SH::ScanDir::sampleName | ( | const std::string & | val_sampleName | ) |
a single sample name into which all found files should be placed.
if set, this overrides all other naming methods.
Definition at line 66 of file ScanDir.cxx.
| ScanDir & SH::ScanDir::samplePattern | ( | const std::string & | val_samplePattern | ) |
the pattern for samples to be accepted
Definition at line 129 of file ScanDir.cxx.
| ScanDir & SH::ScanDir::samplePostfix | ( | const std::string & | val_samplePostfix | ) |
the pattern for the postfix to be stripped from the sampleName
Definition at line 138 of file ScanDir.cxx.
| ScanDir & SH::ScanDir::sampleRename | ( | const std::string & | pattern, |
| const std::string & | name ) |
rename any sample matching pattern to name
Definition at line 148 of file ScanDir.cxx.
| const ScanDir & SH::ScanDir::scan | ( | SampleHandler & | sh, |
| const std::string & | dir ) const |
scan the given directory and put the created samples into the sample handler
Definition at line 167 of file ScanDir.cxx.
| const ScanDir & SH::ScanDir::scan | ( | SampleHandler & | sh, |
| DiskList & | list ) const |
scan the given directory and put the created samples into the sample handler
Definition at line 187 of file ScanDir.cxx.
| const ScanDir & SH::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 at line 177 of file ScanDir.cxx.
|
private |
if m_relSampleDepth is not negative, it is the depth at which we take the sample name, counting from the first directory scanned
|
private |
the value set by directoryPattern, converted to a regular expression
|
private |
the depth set with extraNameComponent, or 0 otherwise
|
private |
the value set by filePattern, converted to a regular expression
|
private |
|
private |
|
private |
|
private |
the value set by sampleName
|
private |
the value set by samplePattern, converted to a regular expression
|
private |
the value set by samplePostfix, converted to a regular expression
|
private |
whether samplePostfix has been set to the empty string
|
private |