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
pool::TokenIterator::TokenIterator
(
FileDescriptor
& fileDescriptor,
16
const
std::string& containerName) :
17
m_container
( nullptr ),
m_refToken
( nullptr )
18
{
19
DbDatabase
dbH( fileDescriptor.
dbc
()->
handle
() );
20
if
( dbH.
isValid
() ) {
21
m_refToken
=
new
Token
(dbH.
cntToken
(containerName));
22
m_container
=
new
DbContainer
(
m_refToken
->technology());
23
}
24
if
( !dbH.
isValid
() || !
m_container
->open(dbH,
m_refToken
->contID(), 0,
m_refToken
->technology(), Io::READ).isSuccess() ) {
25
throw
std::runtime_error(
"Selection from "
+ fileDescriptor.
PFN
() +
"("
+ containerName +
") failed (APR: \" TokenIterator::TokenIterator() \" from \" PersistencySvc \")"
);
26
}
27
}
28
29
pool::TokenIterator::~TokenIterator
()
30
{
31
delete
m_container
;
m_container
=
nullptr
;
32
m_refToken
->release();
m_refToken
=
nullptr
;
33
}
34
35
36
Token
*
37
pool::TokenIterator::next
()
38
{
39
Token::OID_t
linkH(
m_refToken
->oid());
40
if
( !
m_container
->next(linkH).isSuccess() )
return
nullptr
;
41
m_refToken
->oid() = linkH;
42
m_refToken
->addRef();
43
return
m_refToken
;
44
}
45
46
47
std::size_t
48
pool::TokenIterator::size
()
49
{
50
return
m_container
->size();
51
}
52
53
54
bool
55
pool::TokenIterator::seek
(std::size_t position)
56
{
57
if
( position >=
size
() )
return
false
;
58
// go to position-1, so that the next call to next() will return the Token at <position>
59
m_refToken
->oid().second = int(position-1);
60
return
true
;
61
}
DbConnection.h
DbContainer.h
DbDatabase.h
FileDescriptor.h
size
size_t size() const
Number of registered mappings.
TokenIterator.h
Token
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition
Token.h:22
pool::DbConnection::handle
DbDatabaseObj * handle()
Access object identifier.
Definition
DbConnection.h:58
pool::DbContainer
Description: Definition of the object describing a database container Handle managing a DbContainerOb...
Definition
DbContainer.h:48
pool::DbDatabase
Description: Handle managing a DbDatabaseObj, a generic Database object.
Definition
DbDatabase.h:54
pool::DbDatabase::cntToken
const Token * cntToken(const std::string &cntName)
Access local container token (if container exists).
pool::DbHandleBase::isValid
bool isValid() const
Validity check (Objy like).
Definition
DbHandleBase.h:68
pool::FileDescriptor
Description:
Definition
FileDescriptor.h:40
pool::FileDescriptor::dbc
DbConnection * dbc()
Access to file descriptor (READ).
Definition
FileDescriptor.h:83
pool::FileDescriptor::PFN
const std::string & PFN() const
Access to physical file name (READ).
Definition
FileDescriptor.h:73
pool::TokenIterator::m_refToken
Token * m_refToken
Definition
TokenIterator.h:55
pool::TokenIterator::next
virtual Token * next() override final
Advances tne iterator and returns a pointer to next token.
Definition
TokenIterator.cxx:37
pool::TokenIterator::~TokenIterator
~TokenIterator()
Definition
TokenIterator.cxx:29
pool::TokenIterator::size
virtual std::size_t size() override final
Return the size of the collection.
Definition
TokenIterator.cxx:48
pool::TokenIterator::m_container
DbContainer * m_container
Definition
TokenIterator.h:54
pool::TokenIterator::seek
virtual bool seek(std::size_t position) override final
Seek to a given position in the collection.
Definition
TokenIterator.cxx:55
pool::TokenIterator::TokenIterator
TokenIterator(FileDescriptor &fileDescriptor, const std::string &containerName)
Constructor taking as argument the file descriptor, the container name.
Definition
TokenIterator.cxx:15
Token::OID_t
Definition
Token.h:25
Generated on
for ATLAS Offline Software by
1.17.0