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.
StatusCode disconnectDb ()
 Disconnect Database.
StatusCode isValid () const
 Check whether has valid pool::ICollection*.
pool::ICollectionCursorselectAll ()

Private Member Functions

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

Private Attributes

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

Detailed Description

This class provides an interface to POOL collections.

Definition at line 26 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").
inputCollection[IN] name of the collection.
svc[IN] pointer to the PoolSvc.
contextId[IN] id for PoolSvc persistency service to use for input.

Definition at line 26 of file PoolCollectionConverter.cxx.

29 :
30 m_collectionType(collectionType),
32 m_inputCollection(inputCollection),
33 m_contextId(contextId),
34 m_poolSvc(svc),
35 m_poolCollection(nullptr),
36 m_collectionCursor(nullptr),
38}
pool::ICollectionCursor * m_collectionCursor
pool::ICollection * m_poolCollection

◆ ~PoolCollectionConverter()

PoolCollectionConverter::~PoolCollectionConverter ( )
virtual

Destructor.

Definition at line 40 of file PoolCollectionConverter.cxx.

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

◆ PoolCollectionConverter() [2/2]

PoolCollectionConverter::PoolCollectionConverter ( const PoolCollectionConverter & rhs)
private

Member Function Documentation

◆ disconnectDb()

StatusCode PoolCollectionConverter::disconnectDb ( )

Disconnect Database.

Definition at line 91 of file PoolCollectionConverter.cxx.

91 {
92 if (m_poolCollection == nullptr) {
93 return StatusCode::SUCCESS;
94 }
95 if (m_poolCollection->description().type() == "ImplicitCollection") {
96 return m_poolSvc->disconnectDb(m_connection);
97 }
98 return StatusCode::SUCCESS;
99}

◆ initialize()

StatusCode PoolCollectionConverter::initialize ( )

Required by all Gaudi Services.

Definition at line 48 of file PoolCollectionConverter.cxx.

48 {
49 // Find out if the user specified a container
50 const std::string collectionType = m_collectionType;
51 std::string::size_type p_colon = collectionType.rfind(':');
52 if (p_colon != std::string::npos) {
53 m_inputContainer = collectionType.substr(p_colon + 1);
54 m_collectionType = collectionType.substr(0, p_colon);
55 }
56 if (m_collectionType == "ImplicitCollection") {
57 // Check if already prefixed
58 if (m_inputCollection.starts_with( "PFN:")
59 || m_inputCollection.starts_with( "LFN:")
60 || m_inputCollection.starts_with( "FID:")) {
61 // Already prefixed
63 } else {
64 // Prefix with PFN:
65 m_connection = std::format("PFN:{}", m_inputCollection);
66 }
67 try {
68 m_poolCollection = m_poolSvc->createCollection("RootCollection", m_connection, m_inputCollection, m_contextId);
69 } catch (std::exception &e) {
70 m_poolCollection = nullptr;
71 }
72 if (m_poolCollection == nullptr) {
73 // Now set where to look in the implicit file
74 m_inputCollection = std::format("{}(DataHeader)", m_inputContainer);
75 }
76 }
77 try {
78 if (m_poolCollection == nullptr) {
80 }
81 if (m_poolCollection == nullptr && m_collectionType == "ImplicitCollection") {
82 m_inputCollection = std::format("{}_DataHeader", m_inputContainer);
84 }
85 } catch (std::exception &e) {
86 return StatusCode::RECOVERABLE;
87 }
88 return StatusCode::SUCCESS;
89}

◆ isValid()

StatusCode PoolCollectionConverter::isValid ( ) const

Check whether has valid pool::ICollection*.

Definition at line 101 of file PoolCollectionConverter.cxx.

101 {
102 return m_poolCollection != nullptr ? StatusCode::SUCCESS : StatusCode::FAILURE;
103}

◆ operator=()

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

◆ selectAll()

pool::ICollectionCursor & PoolCollectionConverter::selectAll ( )
Returns
ICollectionCursor over all entries

Definition at line 105 of file PoolCollectionConverter.cxx.

105 {
106 delete m_collectionCursor; m_collectionCursor = nullptr;
108 return *m_collectionCursor;
109}

Member Data Documentation

◆ m_collectionCursor

pool::ICollectionCursor* PoolCollectionConverter::m_collectionCursor
private

Definition at line 62 of file PoolCollectionConverter.h.

◆ m_collectionType

std::string PoolCollectionConverter::m_collectionType
private

Definition at line 56 of file PoolCollectionConverter.h.

◆ m_connection

std::string PoolCollectionConverter::m_connection
private

Definition at line 57 of file PoolCollectionConverter.h.

◆ m_contextId

unsigned int PoolCollectionConverter::m_contextId
private

Definition at line 59 of file PoolCollectionConverter.h.

◆ m_inputCollection

std::string PoolCollectionConverter::m_inputCollection
private

Definition at line 58 of file PoolCollectionConverter.h.

◆ m_inputContainer

std::string PoolCollectionConverter::m_inputContainer
private

Definition at line 63 of file PoolCollectionConverter.h.

◆ m_poolCollection

pool::ICollection* PoolCollectionConverter::m_poolCollection
private

Definition at line 61 of file PoolCollectionConverter.h.

◆ m_poolSvc

const IPoolSvc* PoolCollectionConverter::m_poolSvc
private

Definition at line 60 of file PoolCollectionConverter.h.


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