Belle II Software  release-05-02-19
FileCatalog.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Thomas Kuhr *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <map>
14 #include <string>
15 
16 namespace Belle2 {
21  class FileMetaData;
22 
26  class FileCatalog {
27 
28  public:
29 
35  static FileCatalog& Instance();
36 
47  virtual bool registerFile(const std::string& fileName, FileMetaData& metaData, const std::string& oldLFN = "");
48 
56  virtual bool getMetaData(std::string& fileName, FileMetaData& metaData);
57 
64  virtual std::string getPhysicalFileName(const std::string& lfn);
65 
66  private:
67 
71  FileCatalog();
72 
73  typedef std::map<std::string, std::pair<std::string, FileMetaData>> FileMap;
81  bool readCatalog(FileMap& fileMap);
82 
89  bool writeCatalog(const FileMap& fileMap);
90 
91  std::string m_fileName;
92  };
93 
95 } //end of namespace Belle2
Belle2::FileCatalog::Instance
static FileCatalog & Instance()
Static method to get a reference to the FileCatalog instance.
Definition: FileCatalog.cc:25
Belle2::FileCatalog::getPhysicalFileName
virtual std::string getPhysicalFileName(const std::string &lfn)
Get the physical file name for the LFN.
Definition: FileCatalog.cc:182
Belle2::FileCatalog::getMetaData
virtual bool getMetaData(std::string &fileName, FileMetaData &metaData)
Get the metadata of a file with given (logical) file name.
Definition: FileCatalog.cc:144
Belle2::FileCatalog::m_fileName
std::string m_fileName
Name of the file catalog file.
Definition: FileCatalog.h:99
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::FileCatalog::writeCatalog
bool writeCatalog(const FileMap &fileMap)
Write the file catalog to the local file.
Definition: FileCatalog.cc:79
Belle2::FileCatalog::registerFile
virtual bool registerFile(const std::string &fileName, FileMetaData &metaData, const std::string &oldLFN="")
Register a file in the (local) file catalog.
Definition: FileCatalog.cc:92
Belle2::FileCatalog::readCatalog
bool readCatalog(FileMap &fileMap)
Read the file catalog from the local file.
Definition: FileCatalog.cc:56
Belle2::FileCatalog::FileCatalog
FileCatalog()
Constructor: locate local database file.
Definition: FileCatalog.cc:32
Belle2::FileCatalog::FileMap
std::map< std::string, std::pair< std::string, FileMetaData > > FileMap
Map with file catalog content.
Definition: FileCatalog.h:81