00001 #include "DataFormats/Provenance/interface/EventEntryInfo.h"
00002 #include "DataFormats/Provenance/interface/EntryDescriptionRegistry.h"
00003 #include <ostream>
00004
00005
00006
00007
00008
00009 namespace edm {
00010 EventEntryInfo::Transients::Transients() :
00011 moduleDescriptionID_(),
00012 entryDescriptionPtr_(),
00013 noEntryDescription_(false)
00014 {}
00015
00016 EventEntryInfo::EventEntryInfo() :
00017 branchID_(),
00018 productID_(),
00019 productStatus_(productstatus::uninitialized()),
00020 entryDescriptionID_(),
00021 transients_()
00022 {}
00023
00024 EventEntryInfo::EventEntryInfo(BranchID const& bid) :
00025 branchID_(bid),
00026 productID_(),
00027 productStatus_(productstatus::uninitialized()),
00028 entryDescriptionID_(),
00029 transients_()
00030 {}
00031
00032 EventEntryInfo::EventEntryInfo(BranchID const& bid,
00033 ProductStatus status,
00034 ProductID const& pid) :
00035 branchID_(bid),
00036 productID_(pid),
00037 productStatus_(status),
00038 entryDescriptionID_(),
00039 transients_()
00040 {}
00041
00042 EventEntryInfo::EventEntryInfo(BranchID const& bid,
00043 ProductStatus status,
00044 ProductID const& pid,
00045 EntryDescriptionID const& edid) :
00046 branchID_(bid),
00047 productID_(pid),
00048 productStatus_(status),
00049 entryDescriptionID_(edid),
00050 transients_()
00051 {}
00052
00053 EventEntryInfo::EventEntryInfo(BranchID const& bid,
00054 ProductStatus status,
00055 ProductID const& pid,
00056 boost::shared_ptr<EventEntryDescription> edPtr) :
00057 branchID_(bid),
00058 productID_(pid),
00059 productStatus_(status),
00060 entryDescriptionID_(edPtr->id()),
00061 transients_() {
00062 moduleDescriptionID() = edPtr->moduleDescriptionID();
00063 entryDescriptionPtr() = edPtr;
00064 EntryDescriptionRegistry::instance()->insertMapped(*edPtr);
00065 }
00066
00067 EventEntryInfo::EventEntryInfo(BranchID const& bid,
00068 ProductStatus status,
00069 ModuleDescriptionID const& mdid,
00070 ProductID const& pid,
00071 std::vector<BranchID> const& parents) :
00072 branchID_(bid),
00073 productID_(pid),
00074 productStatus_(status),
00075 entryDescriptionID_(),
00076 transients_() {
00077 moduleDescriptionID() = mdid;
00078 entryDescriptionPtr() = boost::shared_ptr<EventEntryDescription>(new EventEntryDescription);
00079 entryDescriptionPtr()->parents() = parents;
00080 entryDescriptionPtr()->moduleDescriptionID() = mdid;
00081 entryDescriptionID_ = entryDescriptionPtr()->id();
00082 EntryDescriptionRegistry::instance()->insertMapped(*entryDescriptionPtr());
00083 }
00084
00085 EventEntryInfo::EventEntryInfo(BranchID const& bid,
00086 ProductStatus status,
00087 ModuleDescriptionID const& mdid) :
00088 branchID_(bid),
00089 productID_(),
00090 productStatus_(status),
00091 entryDescriptionID_(),
00092 transients_() {
00093 moduleDescriptionID() = mdid;
00094 noEntryDescription() = true;
00095 }
00096
00097 EventEntryInfo
00098 EventEntryInfo::makeEntryInfo() const {
00099 return *this;
00100 }
00101
00102 EventEntryDescription const &
00103 EventEntryInfo::entryDescription() const {
00104 if (!entryDescriptionPtr()) {
00105 entryDescriptionPtr().reset(new EventEntryDescription);
00106 EntryDescriptionRegistry::instance()->getMapped(entryDescriptionID_, *entryDescriptionPtr());
00107 moduleDescriptionID() = entryDescriptionPtr()->moduleDescriptionID();
00108 }
00109 return *entryDescriptionPtr();
00110 }
00111
00112 void
00113 EventEntryInfo::setPresent() {
00114 if (productstatus::present(productStatus())) return;
00115 assert(productstatus::unknown(productStatus()));
00116 setStatus(productstatus::present());
00117 }
00118
00119 void
00120 EventEntryInfo::setNotPresent() {
00121 if (productstatus::neverCreated(productStatus())) return;
00122 if (productstatus::dropped(productStatus())) return;
00123 assert(productstatus::unknown(productStatus()));
00124 setStatus(productstatus::neverCreated());
00125 }
00126
00127 void
00128 EventEntryInfo::write(std::ostream& os) const {
00129 os << "branch ID = " << branchID() << '\n';
00130 os << "product ID = " << productID() << '\n';
00131 os << "product status = " << static_cast<int>(productStatus()) << '\n';
00132 if (noEntryDescription()) {
00133 os << "module description ID = " << moduleDescriptionID() << '\n';
00134 } else {
00135 os << "entry description ID = " << entryDescriptionID() << '\n';
00136 }
00137 }
00138
00139 bool
00140 operator==(EventEntryInfo const& a, EventEntryInfo const& b) {
00141 if (a.noEntryDescription() != b.noEntryDescription()) return false;
00142 if (a.noEntryDescription()) {
00143 return
00144 a.branchID() == b.branchID()
00145 && a.productID() == b.productID()
00146 && a.productStatus() == b.productStatus()
00147 && a.moduleDescriptionID() == b.moduleDescriptionID();
00148 }
00149 return
00150 a.branchID() == b.branchID()
00151 && a.productID() == b.productID()
00152 && a.productStatus() == b.productStatus()
00153 && a.entryDescriptionID() == b.entryDescriptionID();
00154 }
00155 }