ATLAS Offline Software
Loading...
Searching...
No Matches
PoolCollectionConverter.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
9
11#include "PoolSvc/IPoolSvc.h"
13
14// Pool
18
19// Gaudi
20#include "GaudiKernel/StatusCode.h"
21
22#include <exception>
23#include <format>
24#include <mutex>
25#include <stdexcept>
26
27//______________________________________________________________________________
29 const std::string& inputCollection,
30 unsigned int contextId,
31 const IPoolSvc* svc) :
32 m_inputCollection(inputCollection),
33 m_contextId(contextId),
34 m_poolSvc(svc),
35 m_poolCollection(nullptr) {
36}
37//______________________________________________________________________________
44//______________________________________________________________________________
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}
65
66//______________________________________________________________________________
68 if (m_poolCollection == nullptr) {
69 return StatusCode::SUCCESS;
70 }
71 return m_poolSvc->disconnectDb(m_inputCollection);
72}
73//______________________________________________________________________________
75 return m_poolCollection != nullptr ? StatusCode::SUCCESS : StatusCode::FAILURE;
76}
77//______________________________________________________________________________
78std::unique_ptr<pool::ICollectionCursor> PoolCollectionConverter::selectAll() {
79 if (m_poolCollection == nullptr)[[unlikely]] {
80 throw std::runtime_error("PoolCollectionConverter::selectAll: m_poolCollection is nullptr.");
81 }
82 return m_poolCollection->cursor();
83}
This file contains the class definition for the IPoolSvc interface class.
static Double_t sc
This file contains the class definition for the PoolCollectionConverter class.
This file contains the class definition for the Token class (migrated from POOL).
This class provides the interface to the APR persistency software.
Definition IPoolSvc.h:35
std::unique_ptr< pool::ICollectionCursor > selectAll()
PoolCollectionConverter(const std::string &inputCollection, unsigned int contextId, const IPoolSvc *svc)
Constructor.
StatusCode disconnectDb()
Disconnect Database.
pool::ICollection * m_poolCollection
StatusCode isValid() const
Check whether has valid pool::ICollection*.
virtual ~PoolCollectionConverter()
Destructor.
StatusCode initialize()
Required by all Gaudi Services.
static ICollection * open(const std::string &name, const std::string &connection="", ISession *session=0)
Opens an existing collection for reading.
#define unlikely(x)