CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Types | Protected Member Functions | Private Types | Private Attributes
edm::TransformerBase Class Reference

#include <TransformerBase.h>

Inheritance diagram for edm::TransformerBase:
edm::global::impl::Transformer< T > edm::limited::impl::Transformer< T > edm::one::impl::Transformer< T > edm::stream::impl::Transformer

Public Member Functions

 TransformerBase ()=default
 
virtual ~TransformerBase () noexcept(false)=default
 

Protected Types

using PreTransformFunction = std::function< std::any(edm::WrapperBase const &, edm::WaitingTaskWithArenaHolder)>
 
using TransformFunction = std::function< std::unique_ptr< edm::WrapperBase >(std::any)>
 

Protected Member Functions

void extendUpdateLookup (ProducerBase const &, ModuleDescription const &iModuleDesc, ProductResolverIndexHelper const &iHelper)
 
std::size_t findMatchingIndex (ProducerBase const &iBase, edm::BranchDescription const &) const
 
ProductResolverIndex prefetchImp (std::size_t iIndex) const
 
void registerTransformAsyncImp (ProducerBase &, EDPutToken, const TypeID &id, std::string instanceName, PreTransformFunction, TransformFunction)
 
void registerTransformImp (ProducerBase &, EDPutToken, const TypeID &id, std::string instanceName, TransformFunction)
 
void transformImpAsync (WaitingTaskHolder iTask, std::size_t iIndex, ProducerBase const &iBase, edm::EventForTransformer &) const
 

Private Types

enum  InfoColumns {
  kResolverIndex, kType, kToken, kPreTransform,
  kTransform
}
 

Private Attributes

SoATuple< ProductResolverIndex, TypeID, EDPutToken, PreTransformFunction, TransformFunctiontransformInfo_
 

Detailed Description

Definition at line 32 of file TransformerBase.h.

Member Typedef Documentation

◆ PreTransformFunction

Definition at line 41 of file TransformerBase.h.

◆ TransformFunction

using edm::TransformerBase::TransformFunction = std::function<std::unique_ptr<edm::WrapperBase>(std::any)>
protected

Definition at line 40 of file TransformerBase.h.

Member Enumeration Documentation

◆ InfoColumns

Constructor & Destructor Documentation

◆ TransformerBase()

edm::TransformerBase::TransformerBase ( )
default

◆ ~TransformerBase()

virtual edm::TransformerBase::~TransformerBase ( )
virtualdefaultnoexcept

Member Function Documentation

◆ extendUpdateLookup()

void edm::TransformerBase::extendUpdateLookup ( ProducerBase const &  iBase,
ModuleDescription const &  iModuleDesc,
ProductResolverIndexHelper const &  iHelper 
)
protected

Definition at line 51 of file TransformerBase.cc.

References edm::ProductResolverIndexHelper::index(), edm::ModuleDescription::moduleLabel(), edm::ModuleDescription::processName(), edm::PRODUCT_TYPE, transformInfo_, and edm::ProducerBase::typeLabelList().

Referenced by edm::stream::impl::Transformer::extendUpdateLookup(), edm::one::impl::Transformer< T >::extendUpdateLookup(), edm::limited::impl::Transformer< T >::extendUpdateLookup(), and edm::global::impl::Transformer< T >::extendUpdateLookup().

53  {
54  auto const& list = iBase.typeLabelList();
55 
56  for (auto it = transformInfo_.begin<0>(); it != transformInfo_.end<0>(); ++it) {
57  auto const& putInfo = list[*it];
58  *it = iHelper.index(PRODUCT_TYPE,
59  putInfo.typeID_,
60  iModuleDesc.moduleLabel().c_str(),
61  putInfo.productInstanceName_.c_str(),
62  iModuleDesc.processName().c_str());
63  }
64  }
SoATuple< ProductResolverIndex, TypeID, EDPutToken, PreTransformFunction, TransformFunction > transformInfo_

◆ findMatchingIndex()

std::size_t edm::TransformerBase::findMatchingIndex ( ProducerBase const &  iBase,
edm::BranchDescription const &  iBranch 
) const
protected

Definition at line 30 of file TransformerBase.cc.

References cms::cuda::assert(), newFWLiteAna::found, edm::BranchDescription::productInstanceName(), edm::ProducerBase::typeLabelList(), and edm::BranchDescription::unwrappedTypeID().

Referenced by edm::stream::impl::Transformer::transformIndex_(), edm::one::impl::Transformer< T >::transformIndex_(), edm::limited::impl::Transformer< T >::transformIndex_(), and edm::global::impl::Transformer< T >::transformIndex_().

31  {
32  auto const& list = iBase.typeLabelList();
33 
34  std::size_t index = 0;
35  bool found = false;
36  for (auto const& element : list) {
37  if (not element.isTransform_) {
38  continue;
39  }
40  if (element.typeID_ == iBranch.unwrappedTypeID() &&
41  element.productInstanceName_ == iBranch.productInstanceName()) {
42  found = true;
43  break;
44  }
45  ++index;
46  }
47  assert(found);
48  return index;
49  }
assert(be >=bs)

◆ prefetchImp()

ProductResolverIndex edm::TransformerBase::prefetchImp ( std::size_t  iIndex) const
inlineprotected

◆ registerTransformAsyncImp()

void edm::TransformerBase::registerTransformAsyncImp ( ProducerBase iBase,
EDPutToken  iToken,
const TypeID id,
std::string  instanceName,
PreTransformFunction  iPreFunc,
TransformFunction  iFunc 
)
protected

Definition at line 20 of file TransformerBase.cc.

References l1ctLayer2EG_cff::id, edm::EDPutToken::index(), eostools::move(), transformInfo_, and edm::ProducerBase::transforms().

Referenced by edm::stream::impl::Transformer::registerTransformAsync(), edm::one::impl::Transformer< T >::registerTransformAsync(), edm::limited::impl::Transformer< T >::registerTransformAsync(), and edm::global::impl::Transformer< T >::registerTransformAsync().

25  {
26  auto transformPut = iBase.transforms(id, std::move(instanceName));
27  transformInfo_.emplace_back(iToken.index(), id, transformPut, std::move(iPreFunc), std::move(iFunc));
28  }
SoATuple< ProductResolverIndex, TypeID, EDPutToken, PreTransformFunction, TransformFunction > transformInfo_
def move(src, dest)
Definition: eostools.py:511

◆ registerTransformImp()

void edm::TransformerBase::registerTransformImp ( ProducerBase iBase,
EDPutToken  iToken,
const TypeID id,
std::string  instanceName,
TransformFunction  iFunc 
)
protected

Definition at line 13 of file TransformerBase.cc.

References l1ctLayer2EG_cff::id, edm::EDPutToken::index(), eostools::move(), transformInfo_, and edm::ProducerBase::transforms().

Referenced by edm::stream::impl::Transformer::registerTransform(), edm::one::impl::Transformer< T >::registerTransform(), edm::limited::impl::Transformer< T >::registerTransform(), and edm::global::impl::Transformer< T >::registerTransform().

14  {
15  auto transformPut = iBase.transforms(id, std::move(instanceName));
17  transformInfo_.emplace_back(iToken.index(), id, transformPut, std::move(ptf), std::move(iFunc));
18  }
std::function< std::any(edm::WrapperBase const &, edm::WaitingTaskWithArenaHolder)> PreTransformFunction
SoATuple< ProductResolverIndex, TypeID, EDPutToken, PreTransformFunction, TransformFunction > transformInfo_
def move(src, dest)
Definition: eostools.py:511

◆ transformImpAsync()

void edm::TransformerBase::transformImpAsync ( edm::WaitingTaskHolder  iHolder,
std::size_t  iIndex,
ProducerBase const &  iBase,
edm::EventForTransformer iEvent 
) const
protected

Definition at line 66 of file TransformerBase.cc.

References any(), utilities::cache(), CMS_SA_ALLOW, edm::WaitingTaskHolder::doneWaiting(), edm::WaitingTaskHolder::group(), patZpeak::handle, iEvent, kPreTransform, kResolverIndex, kToken, kTransform, kType, edm::make_waiting_task(), eostools::move(), Types::optional, edm::ProducerBase::putTokenIndexToProductResolverIndex(), transformInfo_, and findQualityFiles::v.

Referenced by edm::stream::impl::Transformer::transformAsync_(), edm::one::impl::Transformer< T >::transformAsync_(), edm::limited::impl::Transformer< T >::transformAsync_(), and edm::global::impl::Transformer< T >::transformAsync_().

69  {
70  if (transformInfo_.get<kPreTransform>(iIndex)) {
71  std::optional<decltype(iEvent.get(transformInfo_.get<kType>(iIndex), transformInfo_.get<kResolverIndex>(iIndex)))>
72  handle;
73  CMS_SA_ALLOW try {
74  handle = iEvent.get(transformInfo_.get<kType>(iIndex), transformInfo_.get<kResolverIndex>(iIndex));
75  } catch (...) {
76  iHolder.doneWaiting(std::current_exception());
77  return;
78  }
79  if (handle->wrapper()) {
80  auto cache = std::make_shared<std::any>();
81  auto nextTask =
82  edm::make_waiting_task([holder = iHolder, cache, iIndex, this, &iBase, handle = *handle, iEvent](
83  std::exception_ptr const* iPtr) mutable {
84  if (iPtr) {
85  holder.doneWaiting(*iPtr);
86  } else {
87  iEvent.put(iBase.putTokenIndexToProductResolverIndex()[transformInfo_.get<kToken>(iIndex).index()],
88  transformInfo_.get<kTransform>(iIndex)(std::move(*cache)),
89  handle);
90  }
91  });
92  WaitingTaskWithArenaHolder wta(*iHolder.group(), nextTask);
93  CMS_SA_ALLOW try {
94  *cache = transformInfo_.get<kPreTransform>(iIndex)(*(handle->wrapper()), wta);
95  } catch (...) {
96  wta.doneWaiting(std::current_exception());
97  }
98  }
99  } else {
100  CMS_SA_ALLOW try {
101  auto handle = iEvent.get(transformInfo_.get<kType>(iIndex), transformInfo_.get<kResolverIndex>(iIndex));
102 
103  if (handle.wrapper()) {
104  std::any v = handle.wrapper();
105  iEvent.put(iBase.putTokenIndexToProductResolverIndex()[transformInfo_.get<kToken>(iIndex).index()],
106  transformInfo_.get<kTransform>(iIndex)(std::move(v)),
107  handle);
108  }
109  } catch (...) {
110  iHolder.doneWaiting(std::current_exception());
111  }
112  }
113  }
#define CMS_SA_ALLOW
SoATuple< ProductResolverIndex, TypeID, EDPutToken, PreTransformFunction, TransformFunction > transformInfo_
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
oneapi::tbb::task_group * group() const noexcept
int iEvent
Definition: GenABIO.cc:224
void doneWaiting(std::exception_ptr iExcept)
FunctorWaitingTask< F > * make_waiting_task(F f)
Definition: WaitingTask.h:92
optional
Definition: Types.py:198
def cache(function)
Definition: utilities.py:3
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ transformInfo_

SoATuple<ProductResolverIndex, TypeID, EDPutToken, PreTransformFunction, TransformFunction> edm::TransformerBase::transformInfo_
private