CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
edm::InputFileCatalog Class Reference

#include <InputFileCatalog.h>

Public Member Functions

bool empty () const
 
std::vector< std::string > const & fallbackFileNames () const
 
std::vector< FileCatalogItem > const & fileCatalogItems () const
 
std::vector< std::string > const & fileNames () const
 
 InputFileCatalog (std::vector< std::string > const &fileNames, std::string const &override, bool useLFNasPFNifLFNnotFound=false)
 
 InputFileCatalog (std::vector< std::string > const &fileNames, std::string const &override, std::string const &overrideFallback, bool useLFNasPFNifLFNnotFound=false)
 
std::vector< std::string > const & logicalFileNames () const
 
 ~InputFileCatalog ()
 

Static Public Member Functions

static bool isPhysical (std::string const &name)
 

Private Member Functions

void findFile (std::string &pfn, std::string &fallbackPfn, std::string const &lfn, bool useLFNasPFNifLFNnotFound)
 
void init (std::string const &override, std::string const &overrideFallback, bool useLFNasPFNifLFNnotFound)
 

Private Attributes

edm::propagate_const< std::unique_ptr< FileLocator > > fallbackFileLocator_
 
std::vector< std::string > fallbackFileNames_
 
std::vector< FileCatalogItemfileCatalogItems_
 
edm::propagate_const< std::unique_ptr< FileLocator > > fileLocator_
 
std::vector< std::string > fileNames_
 
std::vector< std::string > logicalFileNames_
 
edm::propagate_const< std::unique_ptr< FileLocator > > overrideFallbackFileLocator_
 
edm::propagate_const< std::unique_ptr< FileLocator > > overrideFileLocator_
 

Detailed Description

Definition at line 31 of file InputFileCatalog.h.

Constructor & Destructor Documentation

edm::InputFileCatalog::InputFileCatalog ( std::vector< std::string > const &  fileNames,
std::string const &  override,
bool  useLFNasPFNifLFNnotFound = false 
)

Definition at line 14 of file InputFileCatalog.cc.

References init().

21  fileLocator_(),
25  init(override, "", useLFNasPFNifLFNnotFound);
26  }
std::vector< FileCatalogItem > fileCatalogItems_
std::vector< std::string > fileNames_
edm::propagate_const< std::unique_ptr< FileLocator > > fileLocator_
std::vector< std::string > fallbackFileNames_
edm::propagate_const< std::unique_ptr< FileLocator > > overrideFallbackFileLocator_
edm::propagate_const< std::unique_ptr< FileLocator > > fallbackFileLocator_
std::vector< std::string > const & fileNames() const
edm::propagate_const< std::unique_ptr< FileLocator > > overrideFileLocator_
void init(std::string const &override, std::string const &overrideFallback, bool useLFNasPFNifLFNnotFound)
std::vector< std::string > logicalFileNames_
edm::InputFileCatalog::InputFileCatalog ( std::vector< std::string > const &  fileNames,
std::string const &  override,
std::string const &  overrideFallback,
bool  useLFNasPFNifLFNnotFound = false 
)

Definition at line 28 of file InputFileCatalog.cc.

References init().

36  fileLocator_(),
40  init(override, overrideFallback, useLFNasPFNifLFNnotFound);
41  }
std::vector< FileCatalogItem > fileCatalogItems_
std::vector< std::string > fileNames_
edm::propagate_const< std::unique_ptr< FileLocator > > fileLocator_
std::vector< std::string > fallbackFileNames_
edm::propagate_const< std::unique_ptr< FileLocator > > overrideFallbackFileLocator_
edm::propagate_const< std::unique_ptr< FileLocator > > fallbackFileLocator_
std::vector< std::string > const & fileNames() const
edm::propagate_const< std::unique_ptr< FileLocator > > overrideFileLocator_
void init(std::string const &override, std::string const &overrideFallback, bool useLFNasPFNifLFNnotFound)
std::vector< std::string > logicalFileNames_
edm::InputFileCatalog::~InputFileCatalog ( )

Definition at line 43 of file InputFileCatalog.cc.

43 {}

Member Function Documentation

bool edm::InputFileCatalog::empty ( void  ) const
inline
std::vector<std::string> const& edm::InputFileCatalog::fallbackFileNames ( ) const
inline

Definition at line 44 of file InputFileCatalog.h.

44 { return fallbackFileNames_; }
std::vector< std::string > fallbackFileNames_
std::vector<FileCatalogItem> const& edm::InputFileCatalog::fileCatalogItems ( ) const
inline

Definition at line 41 of file InputFileCatalog.h.

Referenced by edm::RootInputFileSequence::fileCatalogItems().

41 { return fileCatalogItems_; }
std::vector< FileCatalogItem > fileCatalogItems_
std::vector<std::string> const& edm::InputFileCatalog::fileNames ( ) const
inline
void edm::InputFileCatalog::findFile ( std::string &  pfn,
std::string &  fallbackPfn,
std::string const &  lfn,
bool  useLFNasPFNifLFNnotFound 
)
private

Definition at line 95 of file InputFileCatalog.cc.

References fallbackFileLocator_, fileLocator_, overrideFallbackFileLocator_, and overrideFileLocator_.

Referenced by init().

98  {
100  pfn = overrideFileLocator_->pfn(lfn);
101  if (pfn.empty()) {
102  pfn = fileLocator_->pfn(lfn);
103  }
104  } else {
105  pfn = fileLocator_->pfn(lfn);
106  }
107  if (pfn.empty() && useLFNasPFNifLFNnotFound) {
108  pfn = lfn;
109  }
110  // Empty PFN will be found by caller.
111 
113  fallbackPfn = overrideFallbackFileLocator_->pfn(lfn);
114  if (fallbackFileLocator_ && fallbackPfn.empty()) {
115  fallbackPfn = fallbackFileLocator_->pfn(lfn);
116  }
117  } else if (fallbackFileLocator_) {
118  fallbackPfn = fallbackFileLocator_->pfn(lfn);
119  // Empty fallback PFN is OK.
120  }
121  }
edm::propagate_const< std::unique_ptr< FileLocator > > fileLocator_
edm::propagate_const< std::unique_ptr< FileLocator > > overrideFallbackFileLocator_
edm::propagate_const< std::unique_ptr< FileLocator > > fallbackFileLocator_
edm::propagate_const< std::unique_ptr< FileLocator > > overrideFileLocator_
void edm::InputFileCatalog::init ( std::string const &  override,
std::string const &  overrideFallback,
bool  useLFNasPFNifLFNnotFound 
)
private

Definition at line 45 of file InputFileCatalog.cc.

References edm::errors::Configuration, MillePedeFileConverter_cfg::e, Exception, fallbackFileLocator_, fallbackFileNames_, fileCatalogItems_, fileLocator_, fileNames_, findFile(), isPhysical(), logicalFileNames_, overrideFallbackFileLocator_, overrideFileLocator_, and trim().

Referenced by InputFileCatalog().

47  {
48  fileCatalogItems_.reserve(fileNames_.size());
49  typedef std::vector<std::string>::iterator iter;
50  for (iter it = fileNames_.begin(),
51  lt = logicalFileNames_.begin(),
52  itEnd = fileNames_.end(),
53  ft = fallbackFileNames_.begin();
54  it != itEnd;
55  ++it, ++lt, ++ft) {
56  boost::trim(*it);
57  if (it->empty()) {
58  throw Exception(errors::Configuration, "InputFileCatalog::InputFileCatalog()\n")
59  << "An empty string specified in the fileNames parameter for input source.\n";
60  }
61  if (isPhysical(*it)) {
62  if (it->back() == ':') {
63  throw Exception(errors::Configuration, "InputFileCatalog::InputFileCatalog()\n")
64  << "An empty physical file name specified in the fileNames parameter for input source.\n";
65  }
66  // Clear the LFN.
67  lt->clear();
68  } else {
69  if (!fileLocator_) {
70  fileLocator_ = std::make_unique<FileLocator>("", false); // propagate_const<T> has no reset() function
71  }
72  if (!overrideFileLocator_ && !inputOverride.empty()) {
74  std::make_unique<FileLocator>(inputOverride, false); // propagate_const<T> has no reset() function
75  }
76  if (!fallbackFileLocator_) {
77  try {
79  std::make_unique<FileLocator>("", true); // propagate_const<T> has no reset() function
80  } catch (cms::Exception const& e) {
81  // No valid fallback locator is OK too.
82  }
83  }
84  if (!overrideFallbackFileLocator_ && !inputOverrideFallback.empty()) {
86  std::make_unique<FileLocator>(inputOverrideFallback, true); // propagate_const<T> has no reset() function
87  }
88  boost::trim(*lt);
89  findFile(*it, *ft, *lt, useLFNasPFNifLFNnotFound);
90  }
91  fileCatalogItems_.push_back(FileCatalogItem(*it, *lt, *ft));
92  }
93  }
std::vector< FileCatalogItem > fileCatalogItems_
static void trim(std::string &s)
std::vector< std::string > fileNames_
static bool isPhysical(std::string const &name)
edm::propagate_const< std::unique_ptr< FileLocator > > fileLocator_
std::vector< std::string > fallbackFileNames_
edm::propagate_const< std::unique_ptr< FileLocator > > overrideFallbackFileLocator_
edm::propagate_const< std::unique_ptr< FileLocator > > fallbackFileLocator_
edm::propagate_const< std::unique_ptr< FileLocator > > overrideFileLocator_
std::vector< std::string > logicalFileNames_
void findFile(std::string &pfn, std::string &fallbackPfn, std::string const &lfn, bool useLFNasPFNifLFNnotFound)
static bool edm::InputFileCatalog::isPhysical ( std::string const &  name)
inlinestatic

Definition at line 46 of file InputFileCatalog.h.

References init, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by init().

46 { return (name.empty() || name.find(':') != std::string::npos); }
std::vector<std::string> const& edm::InputFileCatalog::logicalFileNames ( ) const
inline

Definition at line 42 of file InputFileCatalog.h.

Referenced by edm::FromFiles::logicalFileNames(), and DQMRootSource::readFile_().

42 { return logicalFileNames_; }
std::vector< std::string > logicalFileNames_

Member Data Documentation

edm::propagate_const<std::unique_ptr<FileLocator> > edm::InputFileCatalog::fallbackFileLocator_
private

Definition at line 57 of file InputFileCatalog.h.

Referenced by findFile(), and init().

std::vector<std::string> edm::InputFileCatalog::fallbackFileNames_
private

Definition at line 53 of file InputFileCatalog.h.

Referenced by init().

std::vector<FileCatalogItem> edm::InputFileCatalog::fileCatalogItems_
private

Definition at line 54 of file InputFileCatalog.h.

Referenced by init().

edm::propagate_const<std::unique_ptr<FileLocator> > edm::InputFileCatalog::fileLocator_
private

Definition at line 55 of file InputFileCatalog.h.

Referenced by findFile(), and init().

std::vector<std::string> edm::InputFileCatalog::fileNames_
private

Definition at line 52 of file InputFileCatalog.h.

Referenced by init().

std::vector<std::string> edm::InputFileCatalog::logicalFileNames_
private

Definition at line 51 of file InputFileCatalog.h.

Referenced by init().

edm::propagate_const<std::unique_ptr<FileLocator> > edm::InputFileCatalog::overrideFallbackFileLocator_
private

Definition at line 58 of file InputFileCatalog.h.

Referenced by findFile(), and init().

edm::propagate_const<std::unique_ptr<FileLocator> > edm::InputFileCatalog::overrideFileLocator_
private

Definition at line 56 of file InputFileCatalog.h.

Referenced by findFile(), and init().