7#include "CoralBase/Attribute.h"
26 if( !fileDescr.
dbc() ) {
27 throw std::runtime_error(
"Collection: file must already be connected: " + fileDescr.PFN() );
34 std::vector<const Token*> containerTokens;
36 if( !db.containers(containerTokens,
false).isSuccess() ) {
37 throw std::runtime_error(
"Collection: error reading " + fileDescr.PFN() );
43 ATH_MSG_DEBUG(
"Opening Collection '" << fileDescr.
PFN() <<
"' using container prefix: " << containerPrefix );
44 std::string tagContName = containerPrefix +
"(";
46 std::set<std::string> seenContainers;
47 for(
const Token *t : containerTokens ) {
49 const std::string& contName = db.cntName(token);
50 const DbTypeInfo* typ_info = db.objectShape( token.classID() );
51 if( contName.starts_with( tagContName ) and !seenContainers.contains( contName ) ) {
52 seenContainers.insert( contName );
53 const std::string& attrName = contName.substr( tagContName.size(), contName.size() - tagContName.size() - 1 );
54 ATH_MSG_DEBUG(
" :container " << contName <<
" with attribute " << attrName <<
" of type: " << typ_info->clazz().Name());
55 DbContainer cnt( db.type() );
56 if( cnt.open( db, contName, typ_info, token.technology(), db.openMode() ).isSuccess() ) {
57 if( attrName != APRDefaults::TokenTypeName ) {
58 if( m_containerMap.contains(attrName) ) {
59 throw std::runtime_error(
"Column with name `" + attrName +
"' already exists." );
61 m_attributeList.extend( attrName, typ_info->clazz().Name() );
63 m_containerMap.emplace( attrName, std::move(cnt) );
65 ATH_MSG_WARNING(
"EventTag container " << contName <<
" could not be opened");
67 }
else if( contName == newDHContName || contName == oldDHContName ) {
68 ATH_MSG_DEBUG(
" :container " << contName <<
" is the DataHeader container");
69 DbContainer cnt( db.type() );
70 if( cnt.open( db, contName, typ_info, token.technology(), db.openMode() ).isSuccess() ) {
71 dhCont = std::move(cnt);
73 ATH_MSG_WARNING(
"EventTag container " << contName <<
" could not be opened");
77 if( m_containerMap.empty() ) {
78 m_containerMap.emplace( APRDefaults::TokenTypeName, std::move(dhCont) );
93 const std::string& attr_name = attr.specification().name();
95 void *obj = attr.addressOfData();
96 if( !container.load( &obj,
nullptr, oid ).isSuccess() ) {
103 std::string tokenStr;
104 if( cnt_token.
contID() == newDHContName || cnt_token.
contID() == oldDHContName ) {
109 void *token_addr = &tokenStr;
114 m_token.fromString( tokenStr );
127 if( position >=
size() ) {
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_VERBOSE(x,...)
This file contains the class definition for the Token class (migrated from POOL).
APRMessaging(const std::string &name)
bool next()
Advances to the next row.
std::map< std::string, DbContainer > m_containerMap
Attribute-name to container mapping for EventTag attributes.
std::size_t size()
Returns the number of rows without advancing the reader.
coral::AttributeList m_attributeList
bool seek(std::size_t position)
Positions the reader before the requested row; next() reads it.
DbContainer m_tokenContainer
Collection(FileDescriptor &fileDescr)
Construct from an already-connected file descriptor.
DbDatabaseObj * handle()
Access object identifier.
Description: This class is a handle managing access and lifetime for the Container implementation obj...
Description: Handle managing a DbDatabaseObj, a generic Database object.
DbConnection * dbc()
Access to file descriptor (READ).
const std::string & PFN() const
Access to physical file name (READ).
const FileID & FID() const
Access to file identifier (READ).
constexpr void toString(std::span< char, StrLen > buf, bool uppercase=true) const noexcept
Automatic conversion to string representation.
This class provides a token that identifies in a unique way objects on the persistent storage.
const std::string & contID() const
Access container identifier.
std::string toString() const
Retrieve the string representation of the token.
Token & setOid(const OID_t &oid)
Set object identifier.
const OID_t & oid() const
Access object identifier.
const Guid & dbID() const
Access database identifier.
std::string getDataHeaderName(std::string_view databaseName)
std::string getEventTagName(std::string_view databaseName)
static constexpr const char * DataHeaderTypeName
static constexpr const char * TokenTypeName