File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed
Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -220,7 +220,7 @@ class Frame {
220220 // / @returns A const pointer to a collection if it is available or a nullptr
221221 // / if it is not
222222 template <ObjectType O>
223- inline const podio::CollectionBase * get (const O& object) const ;
223+ inline const typename O::collection_type * get (const O& object) const ;
224224
225225 // / (Destructively) move a collection into the Frame and get a reference to
226226 // / the inserted collection back for further use.
@@ -416,9 +416,9 @@ inline const podio::CollectionBase* Frame::get(const std::string& name) const {
416416}
417417
418418template <ObjectType O>
419- inline const podio::CollectionBase * Frame::get (const O& object) const {
419+ inline const typename O::collection_type * Frame::get (const O& object) const {
420420 const auto name = m_self->getIDTable ().name (object.id ().collectionID );
421- return get (name.value_or (" " ));
421+ return dynamic_cast < const typename O::collection_type*>( get (name.value_or (" " ) ));
422422}
423423
424424inline void Frame::put (std::unique_ptr<podio::CollectionBase> coll, const std::string& name) {
Original file line number Diff line number Diff line change @@ -444,10 +444,9 @@ TEST_CASE("Frame get from object", "[frame][basics]") {
444444 REQUIRE (frameClusters[0 ] == objectClusters[0 ]);
445445
446446 const auto * collPtr = event.get (cluster);
447+ STATIC_REQUIRE (std::is_same_v<decltype (collPtr), const ExampleClusterCollection*>);
447448 REQUIRE (collPtr != nullptr );
448- const auto * clusterCollPtr = dynamic_cast <const ExampleClusterCollection*>(collPtr);
449- REQUIRE (clusterCollPtr != nullptr );
450- REQUIRE ((*clusterCollPtr)[0 ] == cluster);
449+ REQUIRE ((*collPtr)[0 ] == cluster);
451450}
452451
453452TEST_CASE (" EIC-Jana2 cleanup use case" , " [memory-management][492][174]" ) {
You can’t perform that action at this time.
0 commit comments