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

Reader object for Collections. More...

#include <CollectionCursor.h>

Collaboration diagram for pool::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 27 of file CollectionCursor.h.

Constructor & Destructor Documentation

◆ CollectionCursor()

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

Definition at line 15 of file CollectionCursor.cxx.

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

Member Function Documentation

◆ currentRow()

const pool::CollectionRowBuffer & CollectionCursor::currentRow ( ) const

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

Definition at line 62 of file CollectionCursor.cxx.

63{
65}

◆ eventRef()

const Token & CollectionCursor::eventRef ( ) const

Returns the event reference Token for the current row.

Definition at line 84 of file CollectionCursor.cxx.

85{
86 return m_collectionRowBuffer.token();
87}

◆ next()

bool CollectionCursor::next ( )

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

Definition at line 27 of file CollectionCursor.cxx.

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

75{
76 if( position >= size() ) {
77 return false;
78 }
79 m_idx = position-1;
80 return true;
81}
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 68 of file CollectionCursor.cxx.

69{
70 return m_tokenContainer.size();
71}

Member Data Documentation

◆ m_attrContainers

ContainerMap& pool::CollectionCursor::m_attrContainers
private

Definition at line 54 of file CollectionCursor.h.

◆ m_collectionRowBuffer

CollectionRowBuffer pool::CollectionCursor::m_collectionRowBuffer
private

Row buffer containing the Token and Attributes.

Definition at line 52 of file CollectionCursor.h.

◆ m_idx

std::size_t pool::CollectionCursor::m_idx
private

Definition at line 62 of file CollectionCursor.h.

◆ m_tokenContainer

DbContainer& pool::CollectionCursor::m_tokenContainer
private

Container for the event reference.

Definition at line 57 of file CollectionCursor.h.

◆ m_tokenStr

std::string pool::CollectionCursor::m_tokenStr
private

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

Definition at line 60 of file CollectionCursor.h.


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