Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Euclid::XYDataset::FileSystemProvider Class Reference

The FileSystemProvider handles files in a directory tree. More...

#include <FileSystemProvider.h>

Inheritance diagram for Euclid::XYDataset::FileSystemProvider:
Inheritance graph
[legend]
Collaboration diagram for Euclid::XYDataset::FileSystemProvider:
Collaboration graph
[legend]

Public Member Functions

 FileSystemProvider (const std::string &root_path, std::unique_ptr< FileParser > parser)
 constructor The FileSystemProvider handles files in a directory tree.
 
std::unique_ptr< XYDatasetgetDataset (const QualifiedName &qualified_name) override
 Get a dataset corresponding to an unique qualified name.
 
std::vector< QualifiedNamelistContents (const std::string &group) override
 List all files which belong to a group.
 
std::string getParameter (const QualifiedName &qualified_name, const std::string &key_word) override
 
 ~FileSystemProvider ()=default
 
- Public Member Functions inherited from Euclid::XYDataset::XYDatasetProvider
virtual ~XYDatasetProvider ()=default
 

Private Attributes

std::string m_root_path
 
std::unique_ptr< FileParserm_parser
 
std::map< QualifiedName, std::stringm_name_file_map
 
std::vector< QualifiedNamem_order_names
 

Detailed Description

The FileSystemProvider handles files in a directory tree.

It handles files in a directory tree of the file system. The directory path of the files and the name of the dataset are used for constructing the qualified name to match with the identifier. To support different file formats the work is delegated to the FileParser interface about file related operations (it gets dataset name and data).

Definition at line 57 of file FileSystemProvider.h.

Constructor & Destructor Documentation

◆ FileSystemProvider()

Euclid::XYDataset::FileSystemProvider::FileSystemProvider ( const std::string root_path,
std::unique_ptr< FileParser parser 
)

constructor The FileSystemProvider handles files in a directory tree.

It fills up a map containing the qualified name and the path of the corresponding file.

Parameters
root_pathAbsolute path to the dataset
parserFileParser object
Exceptions
Elements::ExceptionPath to the files not found
Elements::ExceptionRoot path not found
Elements::ExceptionRoot path is not a directory
Elements::ExceptionQualified name can not be inserted

Definition at line 112 of file FileSystemProvider.cpp.

References Euclid::XYDataset::checkEndSlashes(), std::string::empty(), Euclid::XYDataset::getRecursiveDirectoryContents(), std::string::insert(), std::string::length(), m_name_file_map, m_order_names, m_parser, m_root_path, std::string::string(), and std::string::substr().

Here is the call graph for this function:

◆ ~FileSystemProvider()

Euclid::XYDataset::FileSystemProvider::~FileSystemProvider ( )
default

Member Function Documentation

◆ getDataset()

std::unique_ptr< XYDataset > Euclid::XYDataset::FileSystemProvider::getDataset ( const QualifiedName qualified_name)
overridevirtual

Get a dataset corresponding to an unique qualified name.

Parameters
qualified_nameDataset qualified name
Returns
A XYDataset unique pointer or null pointer

Implements Euclid::XYDataset::XYDatasetProvider.

Definition at line 199 of file FileSystemProvider.cpp.

References m_name_file_map, and m_parser.

◆ getParameter()

std::string Euclid::XYDataset::FileSystemProvider::getParameter ( const QualifiedName qualified_name,
const std::string key_word 
)
overridevirtual

Implements Euclid::XYDataset::XYDatasetProvider.

Definition at line 205 of file FileSystemProvider.cpp.

References std::string::find(), m_name_file_map, and m_parser.

Here is the call graph for this function:

◆ listContents()

std::vector< QualifiedName > Euclid::XYDataset::FileSystemProvider::listContents ( const std::string group)
overridevirtual

List all files which belong to a group.

Fill up a vector with qualified name from the map created at the constructor level. In the vector, only qualified name where path contains the group name at the first position is inserted. let's take the following example. if you have a group sets to "A/B/C" and under the "C" repository there is the following structure : C/file1 C/file2 C/D/file3 etc... then the vector of strings returned will contain the following elements: vector[0] = "A/B/C/file1" vector[1] = "A/B/C/file2" vector[3] = "A/B/C/D/file3" etc... Note: The empty string for the group means the root group

Parameters
groupIt is a string which represents a group: e.g. "filter/MER" for getting all MER filters.
Returns
A vector of qualified names for the datasets in the files under the group or an empty vector in case of no files for the group

Implements Euclid::XYDataset::XYDatasetProvider.

Definition at line 165 of file FileSystemProvider.cpp.

References std::string::back(), std::string::empty(), std::string::find_first_not_of(), m_order_names, std::string::pop_back(), std::vector< T >::push_back(), std::string::push_back(), and std::string::substr().

Here is the call graph for this function:

Member Data Documentation

◆ m_name_file_map

std::map<QualifiedName, std::string> Euclid::XYDataset::FileSystemProvider::m_name_file_map
private

Definition at line 125 of file FileSystemProvider.h.

Referenced by FileSystemProvider(), getDataset(), and getParameter().

◆ m_order_names

std::vector<QualifiedName> Euclid::XYDataset::FileSystemProvider::m_order_names
private

Definition at line 126 of file FileSystemProvider.h.

Referenced by FileSystemProvider(), and listContents().

◆ m_parser

std::unique_ptr<FileParser> Euclid::XYDataset::FileSystemProvider::m_parser
private

Definition at line 124 of file FileSystemProvider.h.

Referenced by FileSystemProvider(), getDataset(), and getParameter().

◆ m_root_path

std::string Euclid::XYDataset::FileSystemProvider::m_root_path
private

Definition at line 123 of file FileSystemProvider.h.

Referenced by FileSystemProvider().


The documentation for this class was generated from the following files: