CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
edmtest::OtherThingAlgorithm Class Reference

#include <OtherThingAlgorithm.h>

Public Member Functions

 OtherThingAlgorithm ()
 
void run (edm::Handle< ThingCollection > const &iThingHandle, OtherThingCollection &otherThingCollection, bool useRefs=true, bool refsAreTransient=false) const
 

Private Attributes

int theDebugLevel
 

Detailed Description

Definition at line 12 of file OtherThingAlgorithm.h.

Constructor & Destructor Documentation

◆ OtherThingAlgorithm()

edmtest::OtherThingAlgorithm::OtherThingAlgorithm ( )
inline

Definition at line 14 of file OtherThingAlgorithm.h.

Member Function Documentation

◆ run()

void edmtest::OtherThingAlgorithm::run ( edm::Handle< ThingCollection > const &  iThingHandle,
OtherThingCollection &  otherThingCollection,
bool  useRefs = true,
bool  refsAreTransient = false 
) const

Runs the algorithm and returns a list of OtherThings The user declares the vector and calls this method.

Definition at line 8 of file OtherThingAlgorithm.cc.

References cms::cuda::assert(), mps_fire::i, edm::HandleBase::id(), edm::Ptr< T >::id(), class-composition::parent, edm::Handle< T >::product(), edm::refToPtr(), and mps_fire::result.

Referenced by Types.EventID::cppID(), Types.LuminosityBlockID::cppID(), and edmtest::OtherThingProducer::produce().

11  {
12  const size_t numToMake = 20;
13  result.reserve(numToMake);
14  ThingCollection const* null = nullptr;
15  ThingCollection const* parent = nullptr;
16  if (useRefs) {
17  parent = parentHandle.product();
18  }
19  for (size_t i = 0; i < numToMake; ++i) {
20  OtherThing element;
21  if (!useRefs) {
22  element.a = i;
23  } else if (refsAreTransient) {
24  element.a = i;
25  element.refProd = edm::RefProd<ThingCollection>(parent);
26  element.ref = edm::Ref<ThingCollection>(element.refProd, i);
27  element.refVec.push_back(element.ref);
28  element.refVec.push_back(element.ref);
29  element.refVec.push_back(edm::Ref<ThingCollection>(parent, 19 - i));
30  edm::RefVector<ThingCollection>::iterator ri = element.refVec.begin();
31  element.refVec.erase(ri);
32  element.oneNullOneNot.push_back(edm::Ref<ThingCollection>(null, 0));
33  element.oneNullOneNot.push_back(edm::Ref<ThingCollection>(parent, 0));
34  assert(element.oneNullOneNot.size() == 2); // we'll check this in our tests
35  element.ptr = edm::Ptr<Thing>(&parent->at(i), i);
36  assert(element.ptr == edm::refToPtr(element.ref));
37  element.ptrVec.push_back(element.ptr);
38  element.ptrVec.push_back(edm::Ptr<Thing>(&parent->at(19 - i), 19 - i));
39  element.ptrOneNullOneNot.push_back(edm::Ptr<Thing>(nullptr, 0ul));
40  element.ptrOneNullOneNot.push_back(edm::Ptr<Thing>(&parent->at(0), 0ul));
41  assert(element.ptrOneNullOneNot.size() == 2); // we'll check this in our tests
44  element.refToBaseProd = edm::RefToBaseProd<Thing>(refProd);
45  element.refToBase = edm::RefToBase<Thing>(ref);
46  } else {
47  element.a = i;
48  element.refProd = edm::RefProd<ThingCollection>(parentHandle);
49  element.ref = edm::Ref<ThingCollection>(element.refProd, i);
50  element.refVec.push_back(element.ref);
51  element.refVec.push_back(element.ref);
52  element.refVec.push_back(edm::Ref<ThingCollection>(parentHandle, 19 - i));
53  edm::RefVector<ThingCollection>::iterator ri = element.refVec.begin();
54  element.refVec.erase(ri);
55  element.oneNullOneNot.push_back(edm::Ref<ThingCollection>(parentHandle.id()));
56  element.oneNullOneNot.push_back(edm::Ref<ThingCollection>(parentHandle, 0));
57  assert(element.oneNullOneNot.size() == 2); // we'll check this in our tests
58  element.ptr = edm::Ptr<Thing>(parentHandle, i);
59  assert(element.ptr == edm::refToPtr(element.ref));
60  element.ptrVec.push_back(element.ptr);
61  element.ptrVec.push_back(edm::Ptr<Thing>(parentHandle, 19 - i));
62  element.ptrOneNullOneNot.push_back(edm::Ptr<Thing>(parentHandle.id()));
63  element.ptrOneNullOneNot.push_back(edm::Ptr<Thing>(parentHandle, 0));
64  assert(element.ptrOneNullOneNot.size() == 2); // we'll check this in our tests
67  element.refToBaseProd = edm::RefToBaseProd<Thing>(element.refProd);
68  element.refToBase = edm::RefToBase<Thing>(element.ref);
69  }
70  result.push_back(element);
71  // element.refVec.clear(); // no need to clear; 'element' is created anew on every loop
72  }
73  }
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:160
assert(be >=bs)

Member Data Documentation

◆ theDebugLevel

int edmtest::OtherThingAlgorithm::theDebugLevel
private

Definition at line 24 of file OtherThingAlgorithm.h.