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 &collectionType, const std::string &inputCollection, unsigned int contextId, const IPoolSvc *svc)
 Constructor.
virtual ~PoolCollectionConverter ()
 Destructor.
StatusCode initialize ()
 Required by all Gaudi Services.
pool::ICollectioncreateCollection (const std::string &connection, const std::string &collectionName, const pool::DbType &collectionType, unsigned int contextId) const
StatusCode disconnectDb ()
 Disconnect Database.
StatusCode isValid () const
 Check whether has valid pool::ICollection*.
std::unique_ptr< pool::ICollectionCursorselectAll ()

Private Member Functions

 PoolCollectionConverter (const PoolCollectionConverter &rhs)
PoolCollectionConverteroperator= (const PoolCollectionConverter &rhs)

Private Attributes

std::string m_collectionType
std::string m_inputCollection
unsigned int m_contextId
const IPoolSvcm_poolSvc
pool::ICollectionm_poolCollection

Detailed Description

This class provides an interface to POOL collections.

Definition at line 28 of file PoolCollectionConverter.h.

Constructor & Destructor Documentation

◆ PoolCollectionConverter() [1/2]

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

Constructor.

Parameters
collectionType[IN] type of the collection ("RootCollection", or "ImplicitCollection").
svc[IN] pointer to the PoolSvc.
contextId[IN] id for PoolSvc persistency service to use for input.

Definition at line 30 of file PoolCollectionConverter.cxx.

33 :
34 m_collectionType(collectionType),
35 m_inputCollection(inputCollection),
36 m_contextId(contextId),
37 m_poolSvc(svc),
38 m_poolCollection(nullptr) {
39}
pool::ICollection * m_poolCollection

◆ ~PoolCollectionConverter()

PoolCollectionConverter::~PoolCollectionConverter ( )
virtual

Destructor.

Definition at line 41 of file PoolCollectionConverter.cxx.

41 {
42 if (m_poolCollection) {
43 m_poolCollection->close();
44 delete m_poolCollection; m_poolCollection = nullptr;
45 }
46}

◆ PoolCollectionConverter() [2/2]

PoolCollectionConverter::PoolCollectionConverter ( const PoolCollectionConverter & rhs)
private

Member Function Documentation

◆ createCollection()

pool::ICollection * PoolCollectionConverter::createCollection ( const std::string & connection,
const std::string & collectionName,
const pool::DbType & collectionType,
unsigned int contextId ) const
Returns
a pointer to a Pool Collection.
Parameters
collectionType[IN] string containing the collection type.
connection[IN] string containing the connection.
collectionName[IN] string containing the persistent name of the collection.
contextId[IN] id for PoolSvc persistency service to use for input.

Definition at line 81 of file PoolCollectionConverter.cxx.

84 {
85 // access to these variables is serial, since this is called by event selector only
86 pool::CollectionService collSvc ATLAS_THREAD_SAFE = pool::CollectionService();
87 pool::ICollection* collPtr ATLAS_THREAD_SAFE = nullptr;
88
89 // Try to open EventTags Collection in the input file
90 try {
91 collPtr = collSvc.open(collectionName, collectionType, connection, m_poolSvc->getInputContextSession(contextId));
92 } catch (std::exception &e) {
93 collPtr = nullptr;
94 }
95 return(collPtr);
96}
#define ATLAS_THREAD_SAFE

◆ disconnectDb()

StatusCode PoolCollectionConverter::disconnectDb ( )

Disconnect Database.

Definition at line 98 of file PoolCollectionConverter.cxx.

98 {
99 if (m_poolCollection == nullptr) {
100 return StatusCode::SUCCESS;
101 }
102 return m_poolSvc->disconnectDb(m_inputCollection);
103}

◆ initialize()

StatusCode PoolCollectionConverter::initialize ( )

Required by all Gaudi Services.

Definition at line 48 of file PoolCollectionConverter.cxx.

48 {
49 // Check if already prefixed
50 if (!m_inputCollection.starts_with( "PFN:")
51 && !m_inputCollection.starts_with( "LFN:")
52 && !m_inputCollection.starts_with( "FID:")) {
53 // Prefix with PFN:
54 m_inputCollection = std::format("PFN:{}", m_inputCollection);
55 }
56 StatusCode sc = StatusCode::SUCCESS;
57 try {
58 if (m_collectionType == "RootCollection") {
59 sc = m_poolSvc->connectCollection(m_inputCollection, "Input", pool::ROOT_StorageType.type(), m_contextId);
61 }
62 if (m_poolCollection == nullptr) { // Open as ImplicitCollection if technologies fail, or none was specified
63 sc = m_poolSvc->connectCollection(m_inputCollection, "Input", pool::POOL_StorageType.type(), m_contextId);
65 }
66 } catch (std::exception &e) {
67 if (m_poolCollection == nullptr) return StatusCode::RECOVERABLE;
68 }
69 bool insertFile = false;
70 if (sc.isRecoverable()) {
71 insertFile = true;
72 } else if (sc.isFailure()) {
73 return StatusCode::FAILURE;
74 }
75 if (m_poolCollection == nullptr || insertFile) {
76 return m_poolSvc->checkCollection(m_inputCollection, m_contextId, m_poolCollection == nullptr);
77 }
78 return StatusCode::SUCCESS;
79}
static Double_t sc
pool::ICollection * createCollection(const std::string &connection, const std::string &collectionName, const pool::DbType &collectionType, unsigned int contextId) const
::StatusCode StatusCode
StatusCode definition for legacy code.
static const DbType ROOT_StorageType
Definition DbType.h:85
static const DbType POOL_StorageType
Definition DbType.h:84

◆ isValid()

StatusCode PoolCollectionConverter::isValid ( ) const

Check whether has valid pool::ICollection*.

Definition at line 105 of file PoolCollectionConverter.cxx.

105 {
106 return m_poolCollection != nullptr ? StatusCode::SUCCESS : StatusCode::FAILURE;
107}

◆ operator=()

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

◆ selectAll()

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

Definition at line 109 of file PoolCollectionConverter.cxx.

109 {
110 if (m_poolCollection == nullptr)[[unlikely]] {
111 throw std::runtime_error("PoolCollectionConverter::selectAll: m_poolCollection is nullptr.");
112 }
113 return m_poolCollection->cursor();
114}
#define unlikely(x)

Member Data Documentation

◆ m_collectionType

std::string PoolCollectionConverter::m_collectionType
private

Definition at line 67 of file PoolCollectionConverter.h.

◆ m_contextId

unsigned int PoolCollectionConverter::m_contextId
private

Definition at line 69 of file PoolCollectionConverter.h.

◆ m_inputCollection

std::string PoolCollectionConverter::m_inputCollection
private

Definition at line 68 of file PoolCollectionConverter.h.

◆ m_poolCollection

pool::ICollection* PoolCollectionConverter::m_poolCollection
private

Definition at line 71 of file PoolCollectionConverter.h.

◆ m_poolSvc

const IPoolSvc* PoolCollectionConverter::m_poolSvc
private

Definition at line 70 of file PoolCollectionConverter.h.


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