Belle II Software development
|
InputHandler which will read XML from plain files, optionally gzip compressed. More...
#include <FileHandler.h>
Public Types | |
typedef InputHandler * | Factory(const std::string &uri) |
Factory function which takes a backend uri and returns an InputHandler instance. | |
Public Member Functions | |
FileHandler (const std::string &uri) | |
Instantiate a new file handler, using the uri as base search path. | |
virtual | ~FileHandler () |
empty, virtual destructor | |
virtual InputContext * | open (const std::string &path) override |
create a new FileContext by searching the file system for a file named like path. | |
Protected Attributes | |
std::string | m_path |
Search path to look for files. | |
boost::format | m_pathformat |
format object in case of run-dependent data path | |
bool | m_rundependence {false} |
bool indicating whether the data path is run-dependent | |
std::string | m_uri |
URI for the InputHandler. | |
InputHandler which will read XML from plain files, optionally gzip compressed.
This Handler will try to find the XML files as plain files in the file system. If a file with the exact name cannot be found, the Handler tries to append .gz to the filename and decompress it with gzip.
The uri is the base dir for all files to be searched and can contain the placeholders {EXP} and {RUN} to be replaced with the experiment and run number respectively. Optionally, the placeholders can contain the number of digits the result should have separated by a colon, filled with zeros, e.g. {EXP:4} to have the experiment number starting as 0001
If an file cannot be found (with or without .gz extension), the directory separators "/" will be successively replaced by dashes "-" (starting at the back) to allow for flat file structure. For example, if the uri is /data/ and the filename to be opened is geometry/Belle2.xml, the inputhandler will try to find /data/geometry/Belle2.xml /data/geometry/Belle2.xml.gz /data/geometry-Belle2.xml /data/geometry-Belle2.xml.gz /data-geometry-Belle2.xml /data-geometry-Belle2.xml.gz in that order the search path, stopping at the first success.
Definition at line 67 of file FileHandler.h.
|
inherited |
Factory function which takes a backend uri and returns an InputHandler instance.
Definition at line 53 of file InputHandler.h.
|
explicit |
Instantiate a new file handler, using the uri as base search path.
If uri is empty, the default data search path will be used.
uri | * path to search files in |
Definition at line 35 of file FileHandler.cc.
|
inlinevirtual |
|
overridevirtual |
create a new FileContext by searching the file system for a file named like path.
path | name of the file, relative to the FileHandler search path |
Implements InputHandler.
Definition at line 64 of file FileHandler.cc.
|
protected |
Search path to look for files.
Definition at line 83 of file FileHandler.h.
|
protected |
format object in case of run-dependent data path
Definition at line 85 of file FileHandler.h.
|
protected |
bool indicating whether the data path is run-dependent
Definition at line 87 of file FileHandler.h.
|
protectedinherited |
URI for the InputHandler.
Definition at line 79 of file InputHandler.h.