33 if( !fileDescr.
dbc() ) {
34 throw std::runtime_error(
"Collection: file must already be connected: " + fileDescr.PFN() );
40 std::vector<const Token*> containerTokens;
42 if( !db.containers(containerTokens,
false).isSuccess() ) {
43 throw std::runtime_error(
"Collection: error reading " + fileDescr.PFN() );
49 ATH_MSG_DEBUG(
"Opening Collection '" << fileDescr.
PFN() <<
"' using container prefix: " << containerPrefix );
50 std::string tagContName = containerPrefix +
"(";
52 std::set<std::string> seenContainers;
53 for(
const Token *t : containerTokens ) {
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() ) {
63 if( attrName != CollectionColumn::tokenColumn().name() ) {
64 const auto duplicate = std::find_if(
65 m_attributeColumns.begin(), m_attributeColumns.end(),
66 [&attrName]( const CollectionColumn& column ) {
67 return column.name() == attrName;
69 if( duplicate != m_attributeColumns.end() ) {
70 throw std::runtime_error(
"Column with name `" + attrName +
"' already exists." );
72 m_attributeColumns.emplace_back( attrName, typ_info->clazz().Name() );
74 m_containerMap.emplace( attrName, std::move(cnt) );
76 ATH_MSG_WARNING(
"EventTag container " << contName <<
" could not be opened");
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() ) {
82 m_dhCont = std::move(cnt);
84 ATH_MSG_WARNING(
"EventTag container " << contName <<
" could not be opened");