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
00018 #include "Reflex/Type.h"
00019
00020 #include <iosfwd>
00021 #include <map>
00022 #include <set>
00023 #include <string>
00024
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& moduleLabel,
00046 std::string const& processName,
00047 std::string const& className,
00048 std::string const& friendlyClassName,
00049 std::string const& productInstanceName,
00050 std::string const& moduleName,
00051 ParameterSetID const& parameterSetID,
00052 TypeID const& theTypeID,
00053 bool produced = true,
00054 std::set<std::string> const& aliases = std::set<std::string>());
00055
00056 ~BranchDescription() {}
00057
00058 void init() const {
00059 initBranchName();
00060 initFromDictionary();
00061 }
00062
00063 void initBranchName() const;
00064
00065 void initFromDictionary() const;
00066
00067 void write(std::ostream& os) const;
00068
00069 void merge(BranchDescription const& other);
00070
00071 std::string const& moduleLabel() const {return moduleLabel_;}
00072 std::string const& processName() const {return processName_;}
00073 BranchID const& branchID() const {return branchID_;}
00074 std::string const& fullClassName() const {return fullClassName_;}
00075 std::string const& className() const {return fullClassName();}
00076 std::string const& friendlyClassName() const {return friendlyClassName_;}
00077 std::string const& productInstanceName() const {return productInstanceName_;}
00078 bool& produced() const {return transient_.produced_;}
00079 bool present() const {return !transient_.dropped_;}
00080 bool& dropped() const {return transient_.dropped_;}
00081 bool& onDemand() const {return transient_.onDemand_;}
00082 bool& transient() const {return transient_.transient_;}
00083 Reflex::Type& type() const {return transient_.type_;}
00084 TypeID& typeID() const {return transient_.typeID_;}
00085 int& splitLevel() const {return transient_.splitLevel_;}
00086 int& basketSize() const {return transient_.basketSize_;}
00087
00088 ParameterSetID const& parameterSetID() const {return transient_.parameterSetID_;}
00089 std::string const& moduleName() const {return transient_.moduleName_;}
00090
00091 std::map<ProcessConfigurationID, ParameterSetID>& parameterSetIDs() const {
00092 return transient_.parameterSetIDs_;
00093 }
00094 std::map<ProcessConfigurationID, std::string>& moduleNames() const {
00095 return transient_.moduleNames_;
00096 }
00097 ParameterSetID const& psetID() const;
00098 bool isPsetIDUnique() const {return parameterSetIDs().size() == 1;}
00099 std::set<std::string> const& branchAliases() const {return branchAliases_;}
00100 std::set<std::string>& branchAliases() {return branchAliases_;}
00101 std::string& branchName() const {return transient_.branchName_;}
00102 BranchType const& branchType() const {return branchType_;}
00103 std::string& wrappedName() const {return transient_.wrappedName_;}
00104 WrapperInterfaceBase*& wrapperInterfaceBase() const {return transient_.wrapperInterfaceBase_;}
00105
00106 WrapperInterfaceBase const* getInterface() const;
00107 void setDropped() const {dropped() = true;}
00108 void setOnDemand() const {onDemand() = true;}
00109 void updateFriendlyClassName();
00110
00111 void initializeTransients() const {transient_.reset();}
00112
00113 struct Transients {
00114 Transients();
00115
00116 void reset();
00117
00118
00119
00120 ParameterSetID parameterSetID_;
00121
00122
00123
00124 std::string moduleName_;
00125
00126
00127 std::string branchName_;
00128
00129
00130 std::string wrappedName_;
00131
00132
00133 bool produced_;
00134
00135
00136
00137 bool onDemand_;
00138
00139
00140
00141
00142 bool dropped_;
00143
00144
00145
00146
00147 mutable std::map<ProcessConfigurationID, ParameterSetID> parameterSetIDs_;
00148
00149
00150
00151
00152 mutable std::map<ProcessConfigurationID, std::string> moduleNames_;
00153
00154
00155
00156 bool transient_;
00157
00158
00159
00160 Reflex::Type type_;
00161
00162
00163 TypeID typeID_;
00164
00165
00166 mutable WrapperInterfaceBase* wrapperInterfaceBase_;
00167
00168
00169
00170 int splitLevel_;
00171
00172
00173
00174 int basketSize_;
00175 };
00176
00177 private:
00178 void throwIfInvalid_() const;
00179
00180
00181 BranchType branchType_;
00182
00183
00184
00185 std::string moduleLabel_;
00186
00187
00188 std::string processName_;
00189
00190
00191 mutable BranchID branchID_;
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 Transients transient_;
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