ATLAS Offline Software
Loading...
Searching...
No Matches
TokenIterator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "TokenIterator.h"
10
11#include "GaudiKernel/StatusCode.h"
12
13#include <exception>
14
16 const std::string& containerName) :
17 m_container( nullptr ), m_refToken ( nullptr ) {
18 DbDatabase dbH( fileDescriptor.dbc()->handle() );
19 if ( dbH.isValid() ) {
20 m_refToken = new Token(dbH.cntToken(containerName));
21 m_container = new DbContainer(m_refToken->technology());
22 }
23 if( !dbH.isValid() || !m_container->open(dbH, m_refToken->contID(), 0, m_refToken->technology(), Io::READ).isSuccess() ) {
24 throw std::runtime_error( "Selection from " + fileDescriptor.PFN() + "(" + containerName + ") failed (APR: \" TokenIterator::TokenIterator() \" from \" PersistencySvc \")" );
25 }
26}
27
29 delete m_container; m_container = nullptr;
30 m_refToken->release(); m_refToken = nullptr;
31}
32
34 Token::OID_t linkH(m_refToken->oid());
35 if( !m_container->next(linkH).isSuccess() ) return nullptr;
36 m_refToken->oid() = linkH;
37 m_refToken->addRef();
38 return m_refToken;
39}
40
41bool TokenIterator::seek(std::size_t position) {
42 if( position >= m_container->size() ) return false;
43 // go to position-1, so that the next call to next() will return the Token at <position>
44 m_refToken->oid().second = int(position-1);
45 return true;
46}
DbDatabaseObj * handle()
Access object identifier.
Description: This class is a handle managing access and lifetime for the Container implementation obj...
Definition DbContainer.h:31
Description: Handle managing a DbDatabaseObj, a generic Database object.
Definition DbDatabase.h:37
const Token * cntToken(const std::string &cntName)
Access local container token (if container exists).
bool isValid() const
Validity check (Objy like).
Description:
DbConnection * dbc()
Access to file descriptor (READ).
const std::string & PFN() const
Access to physical file name (READ).
TokenIterator(FileDescriptor &fileDescriptor, const std::string &containerName)
Constructor taking as argument the file descriptor, the container name.
Token * m_refToken
Token * next()
Advances tne iterator and returns a pointer to next token.
DbContainer * m_container
bool seek(std::size_t position)
Seek to a given position in the collection.
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition Token.h:22