Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:29:21

0001 // -*- C++ -*-
0002 //
0003 // Package:     Utilities
0004 // Class  :     ESInputTag
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Thu Feb 19 13:01:56 CST 2009
0011 //
0012 
0013 // system include files
0014 #include <iostream>
0015 #include <vector>
0016 
0017 // user include files
0018 #include "FWCore/Utilities/interface/ESInputTag.h"
0019 #include "FWCore/Utilities/interface/Parse.h"
0020 #include "FWCore/Utilities/interface/EDMException.h"
0021 
0022 using namespace edm;
0023 
0024 ESInputTag::ESInputTag() = default;
0025 
0026 ESInputTag::ESInputTag(std::string moduleLabel, std::string dataLabel)
0027     : module_(std::move(moduleLabel)), data_(std::move(dataLabel)) {}
0028 
0029 ESInputTag::ESInputTag(const std::string& iEncodedValue) {
0030   // string is delimited by colons
0031   std::vector<std::string> tokens = tokenize(iEncodedValue, ":");
0032   int nwords = tokens.size();
0033   if (nwords > 2) {
0034     throw edm::Exception(errors::Configuration, "ESInputTag")
0035         << "ESInputTag " << iEncodedValue << " has " << nwords << " tokens but only up two 2 are allowed.";
0036   }
0037   if (nwords > 0) {
0038     if (nwords != 2) {
0039       throw edm::Exception(errors::Configuration, "ESInputTag")
0040           << "ESInputTag " << iEncodedValue << " must contain a ':' to separate the module and data labels.";
0041     }
0042     module_ = tokens[0];
0043     data_ = tokens[1];
0044   }
0045 }
0046 
0047 //
0048 // const member functions
0049 //
0050 bool ESInputTag::operator==(const edm::ESInputTag& iRHS) const {
0051   return module_ == iRHS.module_ && data_ == iRHS.data_;
0052 }
0053 
0054 std::string ESInputTag::encode() const {
0055   std::string result = module_;
0056   result += ":";
0057   if (!data_.empty()) {
0058     result += data_;
0059   }
0060   return result;
0061 }
0062 
0063 namespace edm {
0064   std::ostream& operator<<(std::ostream& os, ESInputTag const& tag) {
0065     os << "Module label: " << tag.module() << " Data label: " << tag.data();
0066     return os;
0067   }
0068 }  // namespace edm