CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Group.cc
Go to the documentation of this file.
1 /*----------------------------------------------------------------------
2 ----------------------------------------------------------------------*/
4 
7 
8 #include <cassert>
9 
10 namespace edm {
12 
19 
20  void
22  WrapperOwningHolder const& edp,
23  ProductProvenance const& productProvenance) {
24  if(product()) {
26  << "Attempt to insert more than one product on branch " << productData().branchDescription()->branchName() << "\n";
27  }
28  assert(branchDescription().produced());
29  assert(edp.isValid());
30  assert(!provenance()->productProvenanceValid());
31  assert(status() != Present);
32  assert(status() != Uninitialized);
33  setProductProvenance(productProvenance);
34  assert(provenance()->productProvenanceValid());
35  if(productData().getInterface() != 0) {
36  assert(productData().getInterface() == edp.interface());
37  }
38  productData().wrapper_ = edp.product();
39  status_() = Present;
40  }
41 
42  void
44  WrapperOwningHolder const& edp,
45  ProductProvenance& productProvenance) {
46  assert(provenance()->productProvenanceValid());
47  assert(status() == Present);
48  setProductProvenance(productProvenance);
49  mergeTheProduct(edp);
50  }
51 
52  bool
54  return productUnavailable();
55  }
56 
57  void
59  assert(status() == Present);
60  mergeTheProduct(edp);
61  }
62 
63  void
65  if(product()) {
67  << "Attempt to insert more than one product on branch " << productData().branchDescription()->branchName() << "\n";
68  }
69  assert(branchDescription().produced());
70  assert(edp.isValid());
71  assert(status() != Present);
72  assert(status() != Uninitialized);
73  if(productData().getInterface() != 0) {
74  assert(productData().getInterface() == edp.interface());
75  }
76  productData().wrapper_ = edp.product();
77  status_() = Present;
78  }
79 
80  void
82  WrapperOwningHolder const& edp,
83  ProductProvenance const& productProvenance) {
84  assert(!product());
85  assert(!provenance()->productProvenanceValid());
86  setProductProvenance(productProvenance);
87  assert(provenance()->productProvenanceValid());
88  setProduct(edp);
89  }
90 
91  void
93  WrapperOwningHolder const&,
95  assert(0);
96  }
97 
98  void
100  mergeTheProduct(edp);
101  }
102 
103  bool
105  return(!product());
106  }
107 
108  void
110  assert(!product());
111  setProduct(edp);
112  }
113 
114  void
116  if(wrapper().isMergeable()) {
117  wrapper().mergeProduct(edp.wrapper());
118  } else if(wrapper().hasIsProductEqual()) {
119  if(!wrapper().isProductEqual(edp.wrapper())) {
120  LogError("RunLumiMerging")
121  << "Group::mergeGroup\n"
122  << "Two run/lumi products for the same run/lumi which should be equal are not\n"
123  << "Using the first, ignoring the second\n"
124  << "className = " << branchDescription().className() << "\n"
125  << "moduleLabel = " << moduleLabel() << "\n"
126  << "instance = " << productInstanceName() << "\n"
127  << "process = " << processName() << "\n";
128  }
129  } else {
130  LogWarning("RunLumiMerging")
131  << "Group::mergeGroup\n"
132  << "Run/lumi product has neither a mergeProduct nor isProductEqual function\n"
133  << "Using the first, ignoring the second in merge\n"
134  << "className = " << branchDescription().className() << "\n"
135  << "moduleLabel = " << moduleLabel() << "\n"
136  << "instance = " << productInstanceName() << "\n"
137  << "process = " << processName() << "\n";
138  }
139  }
140 
141  void
143  assert (!product());
144  if(!prod.isValid() || !prod.isPresent()) {
146  }
147  assert(productData().getInterface() == prod.interface() || !prod.isValid());
148  productData().wrapper_ = prod.product();
149  }
150 
151  void
154  }
155 
156  // This routine returns true if it is known that currently there is no real product.
157  // If there is a real product, it returns false.
158  // If it is not known if there is a real product, it returns false.
159  bool
161  if(productIsUnavailable()) {
162  return true;
163  }
164  // If there is a product, we know if it is real or a dummy.
165  if(product()) {
166  bool unavailable = !(wrapper().isPresent());
167  if(unavailable) {
169  }
170  return unavailable;
171  }
172  return false;
173  }
174 
175  // This routine returns true if it is known that currently there is no real product.
176  // If there is a real product, it returns false.
177  // If it is not known if there is a real product, it returns false.
178  bool
180  // If unscheduled production, the product is potentially available.
181  if(onDemand()) return false;
182  // The product is available if and only if a product has been put.
183  bool unavailable = !(product() && wrapper().isPresent());
184  return unavailable;
185  }
186 
187  // This routine returns true if the product was deleted early in order to save memory
188  bool
190  return status() == ProductDeleted;
191  }
192 
193  void
196  }
197 
198 
199  bool
201  // If this product is from a the current process,
202  // the provenance is available if and only if a product has been put.
203  if(branchDescription().produced()) {
204  return product() && wrapper().isPresent();
205  }
206  // If this product is from a prior process, the provenance is available,
207  // although the per event part may have been dropped.
208  return true;
209  }
210 
211  TypeID
213  return TypeID(wrapper().interface()->wrappedTypeInfo());
214  }
215 
216  void
218  // Check if the types match.
219  TypeID typeID(prod.dynamicTypeInfo());
220  if(typeID != branchDescription().typeID()) {
221  // Types do not match.
223  << "Product on branch " << branchDescription().branchName() << " is of wrong type.\n"
224  << "It is supposed to be of type " << branchDescription().className() << ".\n"
225  << "It is actually of type " << typeID.className() << ".\n";
226  }
227  }
228 
229  void
230  Group::setProvenance(boost::shared_ptr<BranchMapper> mapper, ProcessHistoryID const& phid, ProductID const& pid) {
231  //assert(!productData().prov_);
233  productData().prov_.setStore(mapper);
235  }
236 
237  void
238  Group::setProvenance(boost::shared_ptr<BranchMapper> mapper, ProcessHistoryID const& phid) {
239  productData().prov_.setStore(mapper);
241  }
242 
243  void
246  }
247 
248  Provenance*
250  return &(productData().prov_);
251  }
252 
253  void
254  Group::write(std::ostream& os) const {
255  // This is grossly inadequate. It is also not critical for the
256  // first pass.
257  os << std::string("Group for product with ID: ")
258  << productID();
259  }
260 }
virtual bool putOrMergeProduct_() const
Definition: Group.cc:104
std::string const & processName() const
Definition: Group.h:81
void setProductUnavailable() const
Definition: Group.h:179
void setProvenance(boost::shared_ptr< BranchMapper > mapper, ProcessHistoryID const &phid, ProductID const &pid)
Definition: Group.cc:230
virtual bool putOrMergeProduct_() const
Definition: Group.cc:53
virtual ProductData const & productData() const
Definition: Group.h:198
WrapperHolder wrapper() const
Definition: Group.h:58
void setProductProvenance(ProductProvenance const &prov) const
Definition: Group.cc:152
virtual void mergeProduct_(WrapperOwningHolder const &edp, ProductProvenance &productProvenance)
Definition: Group.cc:43
void setProcessHistoryID(ProcessHistoryID const &phid)
Definition: Provenance.h:86
virtual ProductData const & productData() const =0
virtual ~InputGroup()
Definition: Group.cc:14
virtual bool productWasDeleted_() const
Definition: Group.cc:189
virtual GroupStatus & status_() const =0
void reallyCheckType(WrapperOwningHolder const &prod) const
Definition: Group.cc:217
std::type_info const & dynamicTypeInfo() const
Definition: WrapperHolder.h:68
bool mergeProduct(void const *newProduct)
Definition: WrapperHolder.h:57
boost::shared_ptr< void const > product() const
Group()
Definition: Group.cc:11
ProductID const & productID() const
Definition: Group.h:104
bool isProductEqual(void const *newProduct) const
Definition: WrapperHolder.h:60
void setProduct(WrapperOwningHolder const &prod) const
Definition: Group.cc:142
virtual ~SourceGroup()
Definition: Group.cc:18
virtual void mergeProduct_(WrapperOwningHolder const &edp, ProductProvenance &productProvenance)
Definition: Group.cc:92
WrapperInterfaceBase const * interface() const
Definition: WrapperHolder.h:80
Provenance prov_
Definition: ProductData.h:47
bool onDemand() const
Definition: Group.h:49
virtual ~UnscheduledGroup()
Definition: Group.cc:17
virtual bool productUnavailable_() const
Definition: Group.cc:179
bool hasIsProductEqual() const
Definition: WrapperHolder.h:53
virtual void putProduct_(WrapperOwningHolder const &edp, ProductProvenance const &productProvenance)
Definition: Group.cc:21
virtual ~Group()
Definition: Group.cc:13
boost::shared_ptr< void const > wrapper_
Definition: ProductData.h:46
void setStore(boost::shared_ptr< BranchMapper > store) const
Definition: Provenance.h:84
std::string const & moduleLabel() const
Definition: Group.h:75
virtual ~ProducedGroup()
Definition: Group.cc:15
TypeID productType() const
Definition: Group.cc:212
eventsetup::produce::Produce produced
Definition: ESProducts.cc:21
void mergeTheProduct(WrapperOwningHolder const &edp) const
Definition: Group.cc:115
std::string const & className() const
boost::shared_ptr< void const > product() const
Definition: Group.h:55
void setProcessHistoryID(ProcessHistoryID const &phid)
Definition: Group.cc:244
virtual void setProductDeleted()
Definition: Group.cc:194
GroupStatus & status() const
Definition: Group.h:228
TypeID const & typeID() const
void setProductID(ProductID const &pid)
Definition: Provenance.h:92
std::string const & branchName() const
boost::shared_ptr< ConstBranchDescription > const & branchDescription() const
Definition: ProductData.h:29
Provenance * provenance() const
Definition: Group.cc:249
std::string const & productInstanceName() const
Definition: Group.h:78
virtual void putProduct_(WrapperOwningHolder const &edp, ProductProvenance const &productProvenance)
Definition: Group.cc:81
bool productIsUnavailable() const
Definition: Group.h:178
bool isValid() const
Definition: WrapperHolder.h:27
bool provenanceAvailable() const
Definition: Group.cc:200
void setProductProvenance(ProductProvenance const &prov) const
Definition: Provenance.cc:126
virtual ~ScheduledGroup()
Definition: Group.cc:16
bool isPresent() const
Definition: WrapperHolder.h:64
bool productUnavailable() const
Definition: Group.h:43
void const * wrapper() const
Definition: WrapperHolder.h:76
ConstBranchDescription const & branchDescription() const
Definition: Group.h:69
virtual bool productUnavailable_() const
Definition: Group.cc:160
void write(std::ostream &os) const
Definition: Group.cc:254