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

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

Definition at line 80 of file InputFileCatalog.cc.

References Exception, 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()) {
      if (!noThrow) {
        throw cms::Exception("LogicalFileNameNotFound", "FileCatalog::findFile()\n")
          << "Logical file name '" << lfn << "' was not found in the file catalog.\n"
          << "If you wanted a local file, you forgot the 'file:' prefix\n"
          << "before the file name in your configuration file.\n";
      }
      pfn = lfn;
    }
    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::vector< std::string > const &  fileNames,
std::string const &  override,
std::string const &  overrideFallback,
bool  noThrow 
) [private]

Definition at line 42 of file InputFileCatalog.cc.

References edm::errors::Configuration, 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, noThrow);
      }
      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().