Go to the documentation of this file.00001 #ifndef DataFormats_Provenance_BranchDescription_h
00002 #define DataFormats_Provenance_BranchDescription_h
00003
00004
00005
00006
00007
00008
00009
00010 #include <iosfwd>
00011 #include <string>
00012 #include <map>
00013 #include <set>
00014
00015 #include "DataFormats/Provenance/interface/ProvenanceFwd.h"
00016 #include "DataFormats/Provenance/interface/BranchType.h"
00017 #include "DataFormats/Provenance/interface/BranchID.h"
00018 #include "DataFormats/Provenance/interface/ProductID.h"
00019 #include "DataFormats/Provenance/interface/ParameterSetID.h"
00020 #include "DataFormats/Provenance/interface/ProcessConfigurationID.h"
00021 #include "DataFormats/Provenance/interface/Transient.h"
00022 #include "FWCore/Utilities/interface/TypeID.h"
00023
00024 #include "Reflex/Type.h"
00025
00026
00027
00028
00029
00030
00031
00032
00033 namespace edm {
00034 class BranchDescription {
00035 public:
00036 static int const invalidSplitLevel = -1;
00037 static int const invalidBasketSize = 0;
00038 enum MatchMode { Strict = 0,
00039 Permissive };
00040
00041 BranchDescription();
00042
00043 BranchDescription(BranchType const& branchType,
00044 std::string const& mdLabel,
00045 std::string const& procName,
00046 std::string const& name,
00047 std::string const& fName,
00048 std::string const& pin,
00049 ModuleDescription const& modDesc,
00050 TypeID const& theTypeID,
00051 std::set<std::string> const& aliases = std::set<std::string>());
00052
00053 ~BranchDescription() {}
00054
00055 void init() const {
00056 initBranchName();
00057 initFromDictionary();
00058 }
00059
00060 void initBranchName() const;
00061
00062 void initFromDictionary() const;
00063
00064 void write(std::ostream& os) const;
00065
00066 void merge(BranchDescription const& other);
00067
00068 std::string const& moduleLabel() const {return moduleLabel_;}
00069 std::string const& processName() const {return processName_;}
00070 BranchID const& branchID() const {return branchID_;}
00071 ProductID const& oldProductID() const {return productID_;}
00072 std::string const& fullClassName() const {return fullClassName_;}
00073 std::string const& className() const {return fullClassName();}
00074 std::string const& friendlyClassName() const {return friendlyClassName_;}
00075 std::string const& productInstanceName() const {return productInstanceName_;}
00076 bool& produced() const {return transients_.get().produced_;}
00077 bool present() const {return !transients_.get().dropped_;}
00078 bool& dropped() const {return transients_.get().dropped_;}
00079 bool& onDemand() const {return transients_.get().onDemand_;}
00080 bool& transient() const {return transients_.get().transient_;}
00081 Reflex::Type& type() const {return transients_.get().type_;}
00082 TypeID& typeID() const {return transients_.get().typeID_;}
00083 int& splitLevel() const {return transients_.get().splitLevel_;}
00084 int& basketSize() const {return transients_.get().basketSize_;}
00085
00086 ParameterSetID const& parameterSetID() const {return transients_.get().parameterSetID_;}
00087 std::string const& moduleName() const {return transients_.get().moduleName_;}
00088
00089 std::map<ProcessConfigurationID, ParameterSetID>& parameterSetIDs() const {
00090 return transients_.get().parameterSetIDs_;
00091 }
00092 std::map<ProcessConfigurationID, std::string>& moduleNames() const {
00093 return transients_.get().moduleNames_;
00094 }
00095 ParameterSetID const& psetID() const;
00096 bool isPsetIDUnique() const {return parameterSetIDs().size() == 1;}
00097 std::set<std::string> const& branchAliases() const {return branchAliases_;}
00098 std::set<std::string>& branchAliases() {return branchAliases_;}
00099 std::string& branchName() const {return transients_.get().branchName_;}
00100 BranchType const& branchType() const {return branchType_;}
00101 std::string& wrappedName() const {return transients_.get().wrappedName_;}
00102
00103 void setDropped() const {dropped() = true;}
00104 void setOnDemand() const {onDemand() = true;}
00105 void updateFriendlyClassName();
00106
00107 struct Transients {
00108 Transients();
00109
00110
00111
00112 ParameterSetID parameterSetID_;
00113
00114
00115
00116 std::string moduleName_;
00117
00118
00119 std::string branchName_;
00120
00121
00122 std::string wrappedName_;
00123
00124
00125 bool produced_;
00126
00127
00128
00129 bool onDemand_;
00130
00131
00132
00133
00134 bool dropped_;
00135
00136
00137
00138
00139 mutable std::map<ProcessConfigurationID, ParameterSetID> parameterSetIDs_;
00140
00141
00142
00143
00144 mutable std::map<ProcessConfigurationID, std::string> moduleNames_;
00145
00146
00147
00148 bool transient_;
00149
00150
00151
00152 Reflex::Type type_;
00153
00154
00155
00156 TypeID typeID_;
00157
00158
00159
00160 int splitLevel_;
00161
00162
00163
00164 int basketSize_;
00165 };
00166
00167 private:
00168 void throwIfInvalid_() const;
00169
00170
00171 BranchType branchType_;
00172
00173
00174
00175 std::string moduleLabel_;
00176
00177
00178 std::string processName_;
00179
00180
00181 mutable BranchID branchID_;
00182
00183
00184
00185
00186 ProductID productID_;
00187
00188
00189 std::string fullClassName_;
00190
00191
00192 std::string friendlyClassName_;
00193
00194
00195
00196 std::string productInstanceName_;
00197
00198
00199 std::set<std::string> branchAliases_;
00200
00201 mutable Transient<Transients> transients_;
00202 };
00203
00204 inline
00205 std::ostream&
00206 operator<<(std::ostream& os, BranchDescription const& p) {
00207 p.write(os);
00208 return os;
00209 }
00210
00211 bool operator<(BranchDescription const& a, BranchDescription const& b);
00212
00213 bool operator==(BranchDescription const& a, BranchDescription const& b);
00214
00215 bool combinable(BranchDescription const& a, BranchDescription const& b);
00216
00217 std::string match(BranchDescription const& a,
00218 BranchDescription const& b,
00219 std::string const& fileName,
00220 BranchDescription::MatchMode m);
00221 }
00222 #endif