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 "DataFormats/Provenance/interface/BranchID.h"
00011 #include "DataFormats/Provenance/interface/BranchType.h"
00012 #include "DataFormats/Provenance/interface/ParameterSetID.h"
00013 #include "DataFormats/Provenance/interface/ProcessConfigurationID.h"
00014 #include "DataFormats/Provenance/interface/ProductID.h"
00015 #include "DataFormats/Provenance/interface/ProvenanceFwd.h"
00016 #include "FWCore/Utilities/interface/TypeID.h"
00017 #include "FWCore/Utilities/interface/TypeWithDict.h"
00018
00019 #include <iosfwd>
00020 #include <map>
00021 #include <set>
00022 #include <string>
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 namespace edm {
00033 class WrapperInterfaceBase;
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& moduleLabel,
00045 std::string const& processName,
00046 std::string const& className,
00047 std::string const& friendlyClassName,
00048 std::string const& productInstanceName,
00049 std::string const& moduleName,
00050 ParameterSetID const& parameterSetID,
00051 TypeWithDict const& theTypeWithDict,
00052 bool produced = true,
00053 std::set<std::string> const& aliases = std::set<std::string>());
00054
00055 BranchDescription(BranchDescription const& aliasForBranch,
00056 std::string const& moduleLabelAlias,
00057 std::string const& poruductInstanceAlias);
00058
00059 ~BranchDescription() {}
00060
00061 void init() const {
00062 initBranchName();
00063 initFromDictionary();
00064 }
00065
00066 void initBranchName() const;
00067
00068 void initFromDictionary() const;
00069
00070 void write(std::ostream& os) const;
00071
00072 void merge(BranchDescription const& other);
00073
00074 std::string const& moduleLabel() const {return moduleLabel_;}
00075 std::string const& processName() const {return processName_;}
00076 BranchID const& branchID() const {return branchID_;}
00077 BranchID const& aliasForBranchID() const {return aliasForBranchID_;}
00078 bool isAlias() const {return aliasForBranchID_.isValid() && produced();}
00079 BranchID const& originalBranchID() const {return aliasForBranchID_.isValid() ? aliasForBranchID_ : branchID_;}
00080 std::string const& fullClassName() const {return fullClassName_;}
00081 std::string const& className() const {return fullClassName();}
00082 std::string const& friendlyClassName() const {return friendlyClassName_;}
00083 std::string const& productInstanceName() const {return productInstanceName_;}
00084 bool& produced() const {return transient_.produced_;}
00085 bool present() const {return !transient_.dropped_;}
00086 bool& dropped() const {return transient_.dropped_;}
00087 bool& onDemand() const {return transient_.onDemand_;}
00088 bool& transient() const {return transient_.transient_;}
00089 TypeWithDict& wrappedType() const {return transient_.wrappedType_;}
00090 TypeWithDict& unwrappedType() const {return transient_.unwrappedType_;}
00091 TypeID wrappedTypeID() const {return TypeID(transient_.wrappedType_.typeInfo());}
00092 TypeID unwrappedTypeID() const {return TypeID(transient_.unwrappedType_.typeInfo());}
00093 int& splitLevel() const {return transient_.splitLevel_;}
00094 int& basketSize() const {return transient_.basketSize_;}
00095
00096 ParameterSetID const& parameterSetID() const {return transient_.parameterSetID_;}
00097 std::string const& moduleName() const {return transient_.moduleName_;}
00098
00099 std::map<ProcessConfigurationID, ParameterSetID>& parameterSetIDs() const {
00100 return transient_.parameterSetIDs_;
00101 }
00102 std::map<ProcessConfigurationID, std::string>& moduleNames() const {
00103 return transient_.moduleNames_;
00104 }
00105 ParameterSetID const& psetID() const;
00106 bool isPsetIDUnique() const {return parameterSetIDs().size() == 1;}
00107 std::set<std::string> const& branchAliases() const {return branchAliases_;}
00108 std::set<std::string>& branchAliases() {return branchAliases_;}
00109 std::string& branchName() const {return transient_.branchName_;}
00110 BranchType const& branchType() const {return branchType_;}
00111 std::string& wrappedName() const {return transient_.wrappedName_;}
00112 WrapperInterfaceBase*& wrapperInterfaceBase() const {return transient_.wrapperInterfaceBase_;}
00113
00114 WrapperInterfaceBase const* getInterface() const;
00115 void setDropped() const {dropped() = true;}
00116 void setOnDemand() const {onDemand() = true;}
00117 void updateFriendlyClassName();
00118
00119 void initializeTransients() const {transient_.reset();}
00120
00121 struct Transients {
00122 Transients();
00123
00124 void reset();
00125
00126
00127
00128 ParameterSetID parameterSetID_;
00129
00130
00131
00132 std::string moduleName_;
00133
00134
00135 std::string branchName_;
00136
00137
00138 std::string wrappedName_;
00139
00140
00141 bool produced_;
00142
00143
00144
00145 bool onDemand_;
00146
00147
00148
00149
00150 bool dropped_;
00151
00152
00153
00154
00155 mutable std::map<ProcessConfigurationID, ParameterSetID> parameterSetIDs_;
00156
00157
00158
00159
00160 mutable std::map<ProcessConfigurationID, std::string> moduleNames_;
00161
00162
00163
00164 bool transient_;
00165
00166
00167 TypeWithDict wrappedType_;
00168
00169
00170 TypeWithDict unwrappedType_;
00171
00172
00173 mutable WrapperInterfaceBase* wrapperInterfaceBase_;
00174
00175
00176
00177 int splitLevel_;
00178
00179
00180
00181 int basketSize_;
00182 };
00183
00184 private:
00185 void throwIfInvalid_() const;
00186
00187
00188 BranchType branchType_;
00189
00190
00191
00192 std::string moduleLabel_;
00193
00194
00195 std::string processName_;
00196
00197
00198 mutable BranchID branchID_;
00199
00200
00201 std::string fullClassName_;
00202
00203
00204 std::string friendlyClassName_;
00205
00206
00207
00208 std::string productInstanceName_;
00209
00210
00211 std::set<std::string> branchAliases_;
00212
00213
00214
00215
00216 mutable BranchID aliasForBranchID_;
00217
00218 mutable Transients transient_;
00219 };
00220
00221 inline
00222 std::ostream&
00223 operator<<(std::ostream& os, BranchDescription const& p) {
00224 p.write(os);
00225 return os;
00226 }
00227
00228 bool operator<(BranchDescription const& a, BranchDescription const& b);
00229
00230 bool operator==(BranchDescription const& a, BranchDescription const& b);
00231
00232 bool combinable(BranchDescription const& a, BranchDescription const& b);
00233
00234 std::string match(BranchDescription const& a,
00235 BranchDescription const& b,
00236 std::string const& fileName,
00237 BranchDescription::MatchMode m);
00238 }
00239 #endif