ATLAS Offline Software
Loading...
Searching...
No Matches
TokenIterator Class Referencefinal

#include <TokenIterator.h>

Collaboration diagram for TokenIterator:

Public Member Functions

 TokenIterator (FileDescriptor &fileDescriptor, const std::string &containerName)
 Constructor taking as argument the file descriptor, the container name.
 ~TokenIterator ()
 TokenIterator (const TokenIterator &)=delete
TokenIterator & operator= (const TokenIterator &)=delete
Token * next ()
 Advances tne iterator and returns a pointer to next token.
bool seek (std::size_t position)
 Seek to a given position in the collection.

Private Attributes

DbContainer * m_container
Token * m_refToken

Detailed Description

Definition at line 17 of file TokenIterator.h.

Constructor & Destructor Documentation

◆ TokenIterator() [1/2]

TokenIterator::TokenIterator ( FileDescriptor & fileDescriptor,
const std::string & containerName )

Constructor taking as argument the file descriptor, the container name.

Definition at line 15 of file TokenIterator.cxx.

16 :
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}
DbDatabaseObj * handle()
Access object identifier.
DbConnection * dbc()
Access to file descriptor (READ).
const std::string & PFN() const
Access to physical file name (READ).
Token * m_refToken
DbContainer * m_container

◆ ~TokenIterator()

TokenIterator::~TokenIterator ( )

Definition at line 28 of file TokenIterator.cxx.

28 {
29 delete m_container; m_container = nullptr;
30 m_refToken->release(); m_refToken = nullptr;
31}

◆ TokenIterator() [2/2]

TokenIterator::TokenIterator ( const TokenIterator & )
delete

Member Function Documentation

◆ next()

Token * TokenIterator::next ( )

Advances tne iterator and returns a pointer to next token.

Returns
Shared Token ptr (refCount+1) if not at the end, nullptr otherwise.

Definition at line 33 of file TokenIterator.cxx.

33 {
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}

◆ operator=()

TokenIterator & TokenIterator::operator= ( const TokenIterator & )
delete

◆ seek()

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

Seek to a given position in the collection.

Parameters
positionThe position to which to seek.
Returns
True if successful, false otherwise.

Definition at line 41 of file TokenIterator.cxx.

41 {
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}

Member Data Documentation

◆ m_container

DbContainer* TokenIterator::m_container
private

Definition at line 41 of file TokenIterator.h.

◆ m_refToken

Token* TokenIterator::m_refToken
private

Definition at line 42 of file TokenIterator.h.


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