CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes

edm::InputFileCatalog Class Reference

#include <InputFileCatalog.h>

List of all members.

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, std::string const &overrideFallback, bool useLFNasPFNifLFNnotFound=false)
 InputFileCatalog (std::vector< std::string > const &fileNames, std::string const &override, 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

boost::scoped_ptr< FileLocatorfallbackFileLocator_
std::vector< std::string > fallbackFileNames_
std::vector< FileCatalogItemfileCatalogItems_
boost::scoped_ptr< FileLocatorfileLocator_
std::vector< std::string > fileNames_
std::vector< std::string > logicalFileNames_
boost::scoped_ptr< FileLocatoroverrideFallbackFileLocator_
boost::scoped_ptr< FileLocatoroverrideFileLocator_

Detailed Description

Definition at line 28 of file InputFileCatalog.h.


Constructor & Destructor Documentation

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

Definition at line 27 of file InputFileCatalog.cc.

References init().

edm::InputFileCatalog::~InputFileCatalog ( )

Definition at line 40 of file InputFileCatalog.cc.

{}

Member Function Documentation

bool edm::InputFileCatalog::empty ( void  ) const [inline]

Definition at line 37 of file InputFileCatalog.h.

References fileCatalogItems_.

Referenced by edm::EDInputSource::EDInputSource().

{return fileCatalogItems_.empty();}
std::vector<std::string> const& edm::InputFileCatalog::fallbackFileNames ( ) const [inline]

Definition at line 36 of file InputFileCatalog.h.

References fallbackFileNames_.

std::vector<FileCatalogItem> const& edm::InputFileCatalog::fileCatalogItems ( ) const [inline]
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 80 of file InputFileCatalog.cc.

References fallbackFileLocator_, fileLocator_, overrideFallbackFileLocator_, and overrideFileLocator_.

Referenced by init().

                                                                                                                             {
    if (overrideFileLocator_) {
      pfn = overrideFileLocator_->pfn(lfn);
      if (pfn.empty()) {
        pfn = fileLocator_->pfn(lfn);
      }
    } else {
      pfn = fileLocator_->pfn(lfn);
    }
    if (pfn.empty() && useLFNasPFNifLFNnotFound) {
      pfn = lfn;
    }
    // Empty PFN will be found by caller.

    if (overrideFallbackFileLocator_) {
      fallbackPfn = overrideFallbackFileLocator_->pfn(lfn);
      if (fallbackFileLocator_ && fallbackPfn.empty()) {
        fallbackPfn = fallbackFileLocator_->pfn(lfn);
      }
    } else if (fallbackFileLocator_) {
      fallbackPfn = fallbackFileLocator_->pfn(lfn);
      // Empty fallback PFN is OK.
    }
  }
void edm::InputFileCatalog::init ( std::string const &  override,
std::string const &  overrideFallback,
bool  useLFNasPFNifLFNnotFound 
) [private]

Definition at line 42 of file InputFileCatalog.cc.

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

Referenced by InputFileCatalog().

                                                                                                                                   {

    fileCatalogItems_.reserve(fileNames_.size());
    typedef std::vector<std::string>::iterator iter;
    for(iter it = fileNames_.begin(), lt = logicalFileNames_.begin(), itEnd = fileNames_.end(), ft = fallbackFileNames_.begin();
        it != itEnd; ++it, ++lt, ++ft) {
      boost::trim(*it);
      if (it->empty()) {
        throw Exception(errors::Configuration, "InputFileCatalog::InputFileCatalog()\n")
          << "An empty string specified in the fileNames parameter for input source.\n";
      }
      if (isPhysical(*it)) {
        // Clear the LFN.
        lt->clear();
      } else {
        if (!fileLocator_) {
          fileLocator_.reset(new FileLocator("", false));
        }
        if (!overrideFileLocator_ && !inputOverride.empty()) {
          overrideFileLocator_.reset(new FileLocator(inputOverride, false));
        }
        if (!fallbackFileLocator_) {
          try {
            fallbackFileLocator_.reset(new FileLocator("", true));
          } catch (cms::Exception const& e) {
            // No valid fallback locator is OK too.
          }
        }
        if (!overrideFallbackFileLocator_ && !inputOverrideFallback.empty()) {
          overrideFallbackFileLocator_.reset(new FileLocator(inputOverrideFallback, true));
        }
        boost::trim(*lt);
        findFile(*it, *ft, *lt, useLFNasPFNifLFNnotFound);
      }
      fileCatalogItems_.push_back(FileCatalogItem(*it, *lt, *ft));
    }
  }
static bool edm::InputFileCatalog::isPhysical ( std::string const &  name) [inline, static]

Definition at line 38 of file InputFileCatalog.h.

Referenced by init().

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

Member Data Documentation

Definition at line 51 of file InputFileCatalog.h.

Referenced by findFile(), and init().

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

Definition at line 47 of file InputFileCatalog.h.

Referenced by fallbackFileNames(), and init().

Definition at line 48 of file InputFileCatalog.h.

Referenced by empty(), fileCatalogItems(), and init().

boost::scoped_ptr<FileLocator> edm::InputFileCatalog::fileLocator_ [private]

Definition at line 49 of file InputFileCatalog.h.

Referenced by findFile(), and init().

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

Definition at line 46 of file InputFileCatalog.h.

Referenced by fileNames(), and init().

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

Definition at line 45 of file InputFileCatalog.h.

Referenced by init(), and logicalFileNames().

Definition at line 52 of file InputFileCatalog.h.

Referenced by findFile(), and init().

Definition at line 50 of file InputFileCatalog.h.

Referenced by findFile(), and init().