Belle II Software  release-08-01-10
FileHandler Class Reference

InputHandler which will read XML from plain files, optionally gzip compressed. More...

#include <FileHandler.h>

Inheritance diagram for FileHandler:
Collaboration diagram for FileHandler:

Public Types

typedef InputHandlerFactory(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. More...
 
virtual ~FileHandler ()
 empty, virtual destructor
 
virtual InputContextopen (const std::string &path) override
 create a new FileContext by searching the file system for a file named like path. More...
 

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ FileHandler()

FileHandler ( const std::string &  uri)
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.

Parameters
uri* path to search files in

Definition at line 35 of file FileHandler.cc.

Member Function Documentation

◆ open()

InputContext * open ( const std::string &  path)
overridevirtual

create a new FileContext by searching the file system for a file named like path.

Parameters
pathname of the file, relative to the FileHandler search path

Implements InputHandler.

Definition at line 64 of file FileHandler.cc.


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