CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/FWCore/Catalog/interface/InputFileCatalog.h

Go to the documentation of this file.
00001 #ifndef FWCore_Catalog_InputFileCatalog_h
00002 #define FWCore_Catalog_InputFileCatalog_h
00003 
00004 //
00005 // Class InputFileCatalog. Services to manage InputFile catalog
00006 //
00008 
00009 #include <string>
00010 #include <vector>
00011 #include "boost/scoped_ptr.hpp"
00012 #include "FWCore/Catalog/interface/FileLocator.h"
00013 
00014 namespace edm {
00015   class FileCatalogItem {
00016   public:
00017     FileCatalogItem() : pfn_(), lfn_(), fallbackPfn_() {}
00018     FileCatalogItem(std::string const& pfn, std::string const& lfn, std::string const& fallbackPfn) : pfn_(pfn), lfn_(lfn), fallbackPfn_(fallbackPfn) {}
00019     std::string const& fileName() const {return pfn_;}
00020     std::string const& logicalFileName() const {return lfn_;}
00021     std::string const& fallbackFileName() const {return fallbackPfn_;}
00022   private:
00023     std::string pfn_;
00024     std::string lfn_;
00025     std::string fallbackPfn_;
00026   };
00027 
00028   class InputFileCatalog {
00029   public:
00030     InputFileCatalog(std::vector<std::string> const& fileNames, std::string const& override, bool useLFNasPFNifLFNnotFound = false);
00031     InputFileCatalog(std::vector<std::string> const& fileNames, std::string const& override, std::string const& overrideFallback, bool useLFNasPFNifLFNnotFound = false);
00032     ~InputFileCatalog();
00033     std::vector<FileCatalogItem> const& fileCatalogItems() const {return fileCatalogItems_;}
00034     std::vector<std::string> const& logicalFileNames() const {return logicalFileNames_;}
00035     std::vector<std::string> const& fileNames() const {return fileNames_;}
00036     std::vector<std::string> const& fallbackFileNames() const {return fallbackFileNames_;}
00037     bool empty() const {return fileCatalogItems_.empty();}
00038     static bool isPhysical(std::string const& name) {
00039       return (name.empty() || name.find(':') != std::string::npos);
00040     }
00041     
00042   private:
00043     void init(std::string const& override, std::string const& overrideFallback, bool useLFNasPFNifLFNnotFound);
00044     void findFile(std::string & pfn, std::string & fallbackPfn, std::string const& lfn, bool useLFNasPFNifLFNnotFound);
00045     std::vector<std::string> logicalFileNames_;
00046     std::vector<std::string> fileNames_;
00047     std::vector<std::string> fallbackFileNames_;
00048     std::vector<FileCatalogItem> fileCatalogItems_;
00049     boost::scoped_ptr<FileLocator> fileLocator_;
00050     boost::scoped_ptr<FileLocator> overrideFileLocator_;
00051     boost::scoped_ptr<FileLocator> fallbackFileLocator_;
00052     boost::scoped_ptr<FileLocator> overrideFallbackFileLocator_;
00053   };
00054 }
00055 
00056 #endif