Construct from an already-connected file descriptor.
32 {
33 if( !fileDescr.dbc() ) {
34 throw std::runtime_error( "Collection: file must already be connected: " + fileDescr.PFN() );
35 }
36
37
38 ATH_MSG_VERBOSE(
"Opening collection '" << fileDescr.PFN() <<
"' in READ mode" );
39
40 std::vector<const Token*> containerTokens;
41 DbDatabase
db( fileDescr.dbc()->handle() );
42 if( !
db.containers(containerTokens,
false).isSuccess() ) {
43 throw std::runtime_error( "Collection: error reading " + fileDescr.PFN() );
44 }
49 ATH_MSG_DEBUG(
"Opening Collection '" << fileDescr.PFN() <<
"' using container prefix: " << containerPrefix );
50 std::string tagContName = containerPrefix + "(";
51
52 std::set<std::string> seenContainers;
53 for( const Token *t : containerTokens ) {
54 Token token(t);
55 const std::string& contName =
db.cntName(token);
56 const DbTypeInfo* typ_info =
db.objectShape( token.classID() );
57 if( contName.starts_with( tagContName ) and !seenContainers.contains( contName ) ) {
58 seenContainers.insert( contName );
59 const std::string&
attrName = contName.substr( tagContName.size(), contName.size() - tagContName.size() - 1 );
60 ATH_MSG_DEBUG(
" :container " << contName <<
" with attribute " << attrName <<
" of type: " << typ_info->clazz().Name());
61 DbContainer
cnt(
db.type() );
62 if(
cnt.open( db, contName, typ_info, token.technology(),
db.openMode() ).isSuccess() ) {
64 const auto duplicate = std::find_if(
66 [&attrName]( const CollectionColumn& column ) {
67 return column.name() == attrName;
68 } );
70 throw std::runtime_error( "Column with name `" + attrName + "' already exists." );
71 }
73 }
75 } else {
76 ATH_MSG_WARNING(
"EventTag container " << contName <<
" could not be opened");
77 }
78 } else if( contName == newDHContName || contName == oldDHContName ) {
79 ATH_MSG_DEBUG(
" :container " << contName <<
" is the DataHeader container");
80 DbContainer
cnt(
db.type() );
81 if(
cnt.open( db, contName, typ_info, token.technology(),
db.openMode() ).isSuccess() ) {
83 } else {
84 ATH_MSG_WARNING(
"EventTag container " << contName <<
" could not be opened");
85 }
86 }
87 }
88 }
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
APRMessaging(const std::string &name)
static const CollectionColumn & tokenColumn()
std::vector< CollectionColumn > m_attributeColumns
std::map< std::string, DbContainer > m_containerMap
Map of container names to container handles for all EventTag attributes in the file.
DbContainer m_dhCont
The DataHeader container, if present, in the file.
std::string getDataHeaderName(std::string_view databaseName)
std::string getEventTagName(std::string_view databaseName)
static constexpr const char * DataHeaderTypeName