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