Go to the documentation of this file.00001 #include "FWCore/Utilities/interface/InputTag.h"
00002 #include "FWCore/Utilities/interface/Parse.h"
00003 #include "FWCore/Utilities/interface/EDMException.h"
00004
00005 namespace edm {
00006
00007 InputTag::InputTag()
00008 : label_(""),
00009 instance_(""),
00010 process_(),
00011 branchType_(NumBranchTypes),
00012 typeID_(),
00013 cachedOffset_(0U),
00014 fillCount_(0),
00015 productRegistry_(0) {
00016 }
00017
00018
00019 InputTag::InputTag(std::string const& label, std::string const& instance, std::string const& processName)
00020 : label_(label),
00021 instance_(instance),
00022 process_(processName),
00023 branchType_(NumBranchTypes),
00024 typeID_(),
00025 cachedOffset_(0U),
00026 fillCount_(0),
00027 productRegistry_(0) {
00028 }
00029
00030 InputTag::InputTag(char const* label, char const* instance, char const* processName)
00031 : label_(label),
00032 instance_(instance),
00033 process_(processName),
00034 branchType_(NumBranchTypes),
00035 typeID_(),
00036 cachedOffset_(0U),
00037 fillCount_(0),
00038 productRegistry_(0) {
00039 }
00040
00041
00042 InputTag::InputTag(std::string const& s)
00043 : label_(""),
00044 instance_(""),
00045 process_(),
00046 branchType_(NumBranchTypes),
00047 cachedOffset_(0U),
00048 fillCount_(0),
00049 productRegistry_(0) {
00050
00051
00052 std::vector<std::string> tokens = tokenize(s, ":");
00053 size_t nwords = tokens.size();
00054 if(nwords > 3) {
00055 throw edm::Exception(errors::Configuration,"InputTag")
00056 << "Input tag " << s << " has " << nwords << " tokens";
00057 }
00058 if(nwords > 0) label_ = tokens[0];
00059 if(nwords > 1) instance_ = tokens[1];
00060 if(nwords > 2) process_=tokens[2];
00061 }
00062
00063 InputTag::~InputTag() {}
00064
00065 bool InputTag::operator==(InputTag const& tag) const {
00066 return (label_ == tag.label_)
00067 && (instance_ == tag.instance_)
00068 && (process_ == tag.process_);
00069 }
00070
00071
00072 std::string InputTag::encode() const {
00073
00074
00075
00076 static std::string const separator(":");
00077 std::string result = label_;
00078 if(!instance_.empty() || !process_.empty()) {
00079 result += separator + instance_;
00080 }
00081 if(!process_.empty()) {
00082 result += separator + process_;
00083 }
00084 return result;
00085 }
00086
00087 std::ostream& operator<<(std::ostream& ost, InputTag const& tag) {
00088 static std::string const process(", process = ");
00089 ost << "InputTag: label = " << tag.label() << ", instance = " << tag.instance()
00090 << (tag.process().empty() ? std::string() : (process + tag.process()));
00091 return ost;
00092 }
00093 }
00094