ATLAS Offline Software
Loading...
Searching...
No Matches
PoolCollectionConverter Class Reference

This class provides an interface to POOL collections. More...

#include <PoolCollectionConverter.h>

Collaboration diagram for PoolCollectionConverter:

Public Member Functions

 PoolCollectionConverter (const std::string &inputCollection, unsigned int contextId, const IPoolSvc *svc)
 Constructor.
virtual ~PoolCollectionConverter ()
 Destructor.
StatusCode initialize ()
 Required by all Gaudi Services.
StatusCode disconnectDb ()
 Disconnect Database.
StatusCode isValid () const
 Check whether has valid pool::ICollection*.
std::unique_ptr< pool::ICollectionCursor > selectAll ()
const std::string & lastError () const

Private Member Functions

 PoolCollectionConverter (const PoolCollectionConverter &rhs)
PoolCollectionConverter & operator= (const PoolCollectionConverter &rhs)

Private Attributes

std::string m_inputCollection
unsigned int m_contextId
const IPoolSvc * m_poolSvc
pool::ICollection * m_poolCollection
std::string m_lastError

Detailed Description

This class provides an interface to POOL collections.

Definition at line 27 of file PoolCollectionConverter.h.

Constructor & Destructor Documentation

◆ PoolCollectionConverter() [1/2]

PoolCollectionConverter::PoolCollectionConverter ( const std::string & inputCollection,
unsigned int contextId,
const IPoolSvc * svc )

Constructor.

Parameters
svc[IN] pointer to the PoolSvc.
contextId[IN] id for PoolSvc persistency service to use for input.

Definition at line 28 of file PoolCollectionConverter.cxx.

31 :
32 m_inputCollection(inputCollection),
33 m_contextId(contextId),
34 m_poolSvc(svc),
35 m_poolCollection(nullptr) {
36}
pool::ICollection * m_poolCollection

◆ ~PoolCollectionConverter()

PoolCollectionConverter::~PoolCollectionConverter ( )
virtual

Destructor.

Definition at line 38 of file PoolCollectionConverter.cxx.

38 {
39 if (m_poolCollection) {
40 m_poolCollection->close();
41 delete m_poolCollection; m_poolCollection = nullptr;
42 }
43}

◆ PoolCollectionConverter() [2/2]

PoolCollectionConverter::PoolCollectionConverter ( const PoolCollectionConverter & rhs)
private

Member Function Documentation

◆ disconnectDb()

StatusCode PoolCollectionConverter::disconnectDb ( )

Disconnect Database.

Definition at line 67 of file PoolCollectionConverter.cxx.

67 {
68 if (m_poolCollection == nullptr) {
69 return StatusCode::SUCCESS;
70 }
71 return m_poolSvc->disconnectDb(m_inputCollection);
72}

◆ initialize()

StatusCode PoolCollectionConverter::initialize ( )

Required by all Gaudi Services.

Definition at line 45 of file PoolCollectionConverter.cxx.

45 {
46 // Check if already prefixed
47 if (!m_inputCollection.starts_with( "PFN:")
48 && !m_inputCollection.starts_with( "LFN:")
49 && !m_inputCollection.starts_with( "FID:")) {
50 // Prefix with PFN:
51 m_inputCollection = std::format("PFN:{}", m_inputCollection);
52 }
53 StatusCode sc = m_poolSvc->connectCollection(m_inputCollection, "Input", m_contextId);
54 try {
56 m_lastError.clear();
57 } catch (std::exception &e) {
58 m_lastError = std::format("Failed to open collection '{}': {}", m_inputCollection, e.what());
59 }
60 if( sc.isRecoverable() || m_poolCollection == nullptr ) {
61 return m_poolSvc->checkCollection(m_inputCollection, m_contextId, m_poolCollection == nullptr);
62 }
63 return StatusCode::SUCCESS;
64}
static Double_t sc
static ICollection * open(const std::string &name, const std::string &connection="", ISession *session=0)
Opens an existing collection for reading.
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ isValid()

StatusCode PoolCollectionConverter::isValid ( ) const

Check whether has valid pool::ICollection*.

Definition at line 74 of file PoolCollectionConverter.cxx.

74 {
75 return m_poolCollection != nullptr ? StatusCode::SUCCESS : StatusCode::FAILURE;
76}

◆ lastError()

const std::string & PoolCollectionConverter::lastError ( ) const
inline

Definition at line 52 of file PoolCollectionConverter.h.

52{ return m_lastError; }

◆ operator=()

PoolCollectionConverter & PoolCollectionConverter::operator= ( const PoolCollectionConverter & rhs)
private

◆ selectAll()

std::unique_ptr< pool::ICollectionCursor > PoolCollectionConverter::selectAll ( )
Returns
ICollectionCursor over all entries

Definition at line 78 of file PoolCollectionConverter.cxx.

78 {
79 if (m_poolCollection == nullptr)[[unlikely]] {
80 throw std::runtime_error("PoolCollectionConverter::selectAll: m_poolCollection is nullptr.");
81 }
82 return m_poolCollection->cursor();
83}
#define unlikely(x)

Member Data Documentation

◆ m_contextId

unsigned int PoolCollectionConverter::m_contextId
private

Definition at line 56 of file PoolCollectionConverter.h.

◆ m_inputCollection

std::string PoolCollectionConverter::m_inputCollection
private

Definition at line 55 of file PoolCollectionConverter.h.

◆ m_lastError

std::string PoolCollectionConverter::m_lastError
private

Definition at line 60 of file PoolCollectionConverter.h.

◆ m_poolCollection

pool::ICollection* PoolCollectionConverter::m_poolCollection
private

Definition at line 58 of file PoolCollectionConverter.h.

◆ m_poolSvc

const IPoolSvc* PoolCollectionConverter::m_poolSvc
private

Definition at line 57 of file PoolCollectionConverter.h.


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