ATLAS Offline Software
Loading...
Searching...
No Matches
CollectionCursor Class Reference

Reader object for Collections. More...

#include <CollectionCursor.h>

Collaboration diagram for CollectionCursor:

Public Member Functions

 CollectionCursor (const CollectionRowBuffer &collectionRowBuffer, ContainerMap &attrContainers)
bool next ()
 Advances the cursor to the next row of the result set.
const CollectionRowBuffer & currentRow () const
 Returns the selected Tokens and Attributes for the current row of the result set.
std::size_t size ()
 Return the size of the collection.
bool seek (std::size_t position)
 Seeks the cursor to a given position in the collection.
const Token & eventRef () const
 Returns the event reference Token for the current row.

Private Attributes

CollectionRowBuffer m_collectionRowBuffer
 Row buffer containing the Token and Attributes.
ContainerMap & m_attrContainers
DbContainer & m_tokenContainer
 Container for the event reference.
std::string m_tokenStr
 Temporary storage for Event Reference in string format as it is in RNTuple.
std::size_t m_idx

Detailed Description

Reader object for Collections.

Definition at line 24 of file CollectionCursor.h.

Constructor & Destructor Documentation

◆ CollectionCursor()

CollectionCursor::CollectionCursor ( const CollectionRowBuffer & collectionRowBuffer,
ContainerMap & attrContainers )

Definition at line 13 of file CollectionCursor.cxx.

17 : m_collectionRowBuffer( collectionRowBuffer ),
18 m_attrContainers( containers ),
20 m_idx( -1 )
21{
22}
static const CollectionColumn & tokenColumn()
ContainerMap & m_attrContainers
DbContainer & m_tokenContainer
Container for the event reference.
CollectionRowBuffer m_collectionRowBuffer
Row buffer containing the Token and Attributes.

Member Function Documentation

◆ currentRow()

const CollectionRowBuffer & CollectionCursor::currentRow ( ) const

Returns the selected Tokens and Attributes for the current row of the result set.

Definition at line 60 of file CollectionCursor.cxx.

61{
63}

◆ eventRef()

const Token & CollectionCursor::eventRef ( ) const

Returns the event reference Token for the current row.

Definition at line 82 of file CollectionCursor.cxx.

83{
84 return m_collectionRowBuffer.token();
85}

◆ next()

bool CollectionCursor::next ( )

Advances the cursor to the next row of the result set.

Definition at line 25 of file CollectionCursor.cxx.

26{
27 if( ++m_idx >= size() ) {
28 return false;
29 }
30 // read the row
31 Token cnt_token(m_tokenContainer.token());
32 Token::OID_t oid { cnt_token.oid().first, (std::int64_t)m_idx };
33 for( auto& attr : m_collectionRowBuffer.attributeList() ) {
34 const std::string& attr_name = attr.specification().name();
35 DbContainer &container = m_attrContainers.at( attr_name );
36 void *obj = attr.addressOfData();
37 if( !container.load( &obj, nullptr, oid ).isSuccess() ) {
38 return false;
39 }
40 }
41
42 const std::string& newDHContName = std::format("{}(DataHeader)", APRDefaults::ReadConfig::getDataHeaderName( cnt_token.dbID().toString() ));
43 const std::string& oldDHContName = std::format("{}_DataHeader", APRDefaults::ReadConfig::getDataHeaderName( cnt_token.dbID().toString() ));
44 if( cnt_token.contID() == newDHContName || cnt_token.contID() == oldDHContName ) {
45 cnt_token.setOid(oid);
46 m_tokenStr = cnt_token.toString();
47 } else {
48 // read the Token
49 void *token_addr = &m_tokenStr;
50 if( !m_tokenContainer.load( &token_addr, nullptr, oid ).isSuccess() ) {
51 return false;
52 }
53 }
54 m_collectionRowBuffer.token().fromString( m_tokenStr );
55 return true;
56}
std::string m_tokenStr
Temporary storage for Event Reference in string format as it is in RNTuple.
std::size_t size()
Return the size of the collection.
std::string getDataHeaderName(std::string_view databaseName)
const SG::AuxVectorData * container() const
Return the container holding this element.

◆ seek()

bool CollectionCursor::seek ( std::size_t position)

Seeks the cursor to a given position in the collection.

Definition at line 72 of file CollectionCursor.cxx.

73{
74 if( position >= size() ) {
75 return false;
76 }
77 m_idx = position-1;
78 return true;
79}
const Amg::Vector3D & position() const
Method to retrieve the position of the Intersection.

◆ size()

std::size_t CollectionCursor::size ( )

Return the size of the collection.

Definition at line 66 of file CollectionCursor.cxx.

67{
68 return m_tokenContainer.size();
69}

Member Data Documentation

◆ m_attrContainers

ContainerMap& CollectionCursor::m_attrContainers
private

Definition at line 51 of file CollectionCursor.h.

◆ m_collectionRowBuffer

CollectionRowBuffer CollectionCursor::m_collectionRowBuffer
private

Row buffer containing the Token and Attributes.

Definition at line 49 of file CollectionCursor.h.

◆ m_idx

std::size_t CollectionCursor::m_idx
private

Definition at line 59 of file CollectionCursor.h.

◆ m_tokenContainer

DbContainer& CollectionCursor::m_tokenContainer
private

Container for the event reference.

Definition at line 54 of file CollectionCursor.h.

◆ m_tokenStr

std::string CollectionCursor::m_tokenStr
private

Temporary storage for Event Reference in string format as it is in RNTuple.

Definition at line 57 of file CollectionCursor.h.


The documentation for this class was generated from the following files: