ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Database
AthenaPOOL
PoolSvc
src
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
"
6
#include "
StorageSvc/DbDatabase.h
"
7
#include "
StorageSvc/DbContainer.h
"
8
#include "
StorageSvc/DbConnection.h
"
9
#include "
StorageSvc/FileDescriptor.h
"
10
11
#include "GaudiKernel/StatusCode.h"
12
13
#include <exception>
14
15
TokenIterator::TokenIterator
(
FileDescriptor
& fileDescriptor,
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
28
TokenIterator::~TokenIterator
() {
29
delete
m_container
;
m_container
=
nullptr
;
30
m_refToken
->release();
m_refToken
=
nullptr
;
31
}
32
33
Token
*
TokenIterator::next
() {
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
41
bool
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
}
DbConnection.h
DbContainer.h
DbDatabase.h
FileDescriptor.h
TokenIterator.h
DbConnection::handle
DbDatabaseObj * handle()
Access object identifier.
Definition
DbConnection.h:51
DbContainer
Description: This class is a handle managing access and lifetime for the Container implementation obj...
Definition
DbContainer.h:31
DbDatabase
Description: Handle managing a DbDatabaseObj, a generic Database object.
Definition
DbDatabase.h:37
DbDatabase::cntToken
const Token * cntToken(const std::string &cntName)
Access local container token (if container exists).
DbHandleBase::isValid
bool isValid() const
Validity check (Objy like).
Definition
DbHandleBase.h:54
FileDescriptor
Description:
Definition
FileDescriptor.h:26
FileDescriptor::dbc
DbConnection * dbc()
Access to file descriptor (READ).
Definition
FileDescriptor.h:69
FileDescriptor::PFN
const std::string & PFN() const
Access to physical file name (READ).
Definition
FileDescriptor.h:59
TokenIterator::TokenIterator
TokenIterator(FileDescriptor &fileDescriptor, const std::string &containerName)
Constructor taking as argument the file descriptor, the container name.
Definition
TokenIterator.cxx:15
TokenIterator::m_refToken
Token * m_refToken
Definition
TokenIterator.h:42
TokenIterator::next
Token * next()
Advances tne iterator and returns a pointer to next token.
Definition
TokenIterator.cxx:33
TokenIterator::m_container
DbContainer * m_container
Definition
TokenIterator.h:41
TokenIterator::seek
bool seek(std::size_t position)
Seek to a given position in the collection.
Definition
TokenIterator.cxx:41
TokenIterator::~TokenIterator
~TokenIterator()
Definition
TokenIterator.cxx:28
Token
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition
Token.h:22
Token::OID_t
Definition
Token.h:25
Generated on
for ATLAS Offline Software by
1.17.0