|
MARLEY (Model of Argon Reaction Low Energy Yields) v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
|
Singleton class that handles file searches. More...
#include <FileManager.hh>
Public Member Functions | |
| FileManager (const FileManager &)=delete | |
| Deleted copy constructor. | |
| FileManager (FileManager &&)=delete | |
| Deleted move constructor. | |
| std::string | find_file (const std::string &base_name, const std::string &search_path=marley::FileManager::default_search_path_) const |
| Searches for a file in the given search path. | |
| std::string | find_file (const std::string &base_name, const std::vector< std::string > &search_dirs) const |
| Searches for a file in the given directories. | |
| std::vector< std::string > | list_all_files (const std::string &search_path=FileManager::default_search_path_) const |
| Get a vector of full paths for all regular files in the requested search path. | |
| std::vector< std::string > | list_all_files (const std::vector< std::string > &search_dirs) const |
| Get a vector of full paths for all regular files in the requested directories. | |
| std::string | marley_dir () const |
| Returns the path to the root MARLEY folder. | |
| FileManager & | operator= (const FileManager &)=delete |
| Deleted copy assignment operator. | |
| FileManager & | operator= (FileManager &&)=delete |
| Deleted move assignment operator. | |
Static Public Member Functions | |
| static const FileManager & | Instance () |
| Get a const reference to the singleton instance of the FileManager. | |
| static std::vector< std::string > | search_path_to_dir_vector (const std::string &search_path=FileManager::default_search_path_) |
| Converts a ':'-delimited search path (given as a single string) into a vector of directory names. | |
Protected Member Functions | |
| FileManager () | |
| Create the singleton FileManager object. | |
Static Protected Member Functions | |
| static bool | dir_iterate (const std::string &dir_name, const std::function< bool(const std::string &, const std::string &)> &func) |
| Helper function that executes a std::function on the name of each regular file found while scanning through a single directory (non-recursively) | |
Protected Attributes | |
| std::string | marley_dir_ |
| Stores the value of the MARLEY environment variable (which points to the root folder of the source code distribution) | |
Static Protected Attributes | |
| static std::string | default_search_path_ |
| By default, use this search path when looking for files. | |
Singleton class that handles file searches.
Definition at line 25 of file FileManager.hh.
|
protected |
Create the singleton FileManager object.
Definition at line 44 of file FileManager.cc.
References default_search_path_, and marley_dir_.
|
staticprotected |
Helper function that executes a std::function on the name of each regular file found while scanning through a single directory (non-recursively)
| dir_name | The name of the directory to be scanned |
| func | The function to execute. The first argument is the full file name (including the path). The second is the base name of the file (no path). The return value should be true if no further iterations are needed (e.g., because a file matching a desired name was found) and false otherwise. |
Definition at line 175 of file FileManager.cc.
Referenced by find_file(), and list_all_files().
| std::string marley::FileManager::find_file | ( | const std::string & | base_name, |
| const std::string & | search_path = marley::FileManager::default_search_path_ ) const |
Searches for a file in the given search path.
The search is non-recursive, i.e., no subdirectories are included in the search
| base_name | The base name (file name without any path) of the desired file |
| search_path | A string containing a ':'-delimited list of directories that should be searched for the file |
Definition at line 88 of file FileManager.cc.
References find_file(), and search_path_to_dir_vector().
| std::string marley::FileManager::find_file | ( | const std::string & | base_name, |
| const std::vector< std::string > & | search_dirs ) const |
Searches for a file in the given directories.
The search is non-recursive, i.e., no subdirectories are included in the search. If base_name contains directory separators, it is treated as a relative path and resolved against each search directory.
| base_name | The base name (file name without any path) of the desired file, or a relative path containing directory separators |
| search_dirs | A vector of strings specifying the directories that should be searched for the file |
Definition at line 95 of file FileManager.cc.
References dir_iterate().
Referenced by marley::StrengthVariationWeightCalculator::create_instances(), and find_file().
|
static |
Get a const reference to the singleton instance of the FileManager.
Definition at line 69 of file FileManager.cc.
Referenced by marley::MassTable::MassTable(), marley::StrengthVariationWeightCalculator::create_instances(), marley::EventFileReader::deduce_file_format(), marley::StructureDatabase::get_decay_scheme(), and marley::StructureDatabase::load_optical_model_params().
| std::vector< std::string > marley::FileManager::list_all_files | ( | const std::string & | search_path = FileManager::default_search_path_ | ) | const |
Get a vector of full paths for all regular files in the requested search path.
Files in subdirectories are not included (the search is non-recursive)
| search_path | A string containing a ':'-delimited list of directories that should be scanned for files |
Definition at line 139 of file FileManager.cc.
References list_all_files(), and search_path_to_dir_vector().
| std::vector< std::string > marley::FileManager::list_all_files | ( | const std::vector< std::string > & | search_dirs | ) | const |
Get a vector of full paths for all regular files in the requested directories.
Files in subdirectories are not included (the search is non-recursive)
| search_dirs | A vector of strings specifying the directories that should be scanned |
Definition at line 148 of file FileManager.cc.
References dir_iterate().
Referenced by list_all_files().
|
inline |
Returns the path to the root MARLEY folder.
Definition at line 106 of file FileManager.hh.
References marley_dir_.
|
static |
Converts a ':'-delimited search path (given as a single string) into a vector of directory names.
| search_path | The search path to convert that should be searched for the file |
Definition at line 80 of file FileManager.cc.
Referenced by find_file(), and list_all_files().
|
staticprotected |
By default, use this search path when looking for files.
Definition at line 128 of file FileManager.hh.
Referenced by FileManager(), and operator=().
|
protected |
Stores the value of the MARLEY environment variable (which points to the root folder of the source code distribution)
Definition at line 132 of file FileManager.hh.
Referenced by FileManager(), and marley_dir().