Construct from an already-connected file descriptor.
30{
31 if( !fileDescr.
dbc() ) {
32 throw std::runtime_error(
"Collection: file must already be connected: " + fileDescr.
PFN() );
33 }
34
35
37
38 std::vector<const Token*> containerTokens;
40 if( !
db.containers(containerTokens,
false).isSuccess() ) {
41 throw std::runtime_error(
"Collection: error reading " + fileDescr.
PFN() );
42 }
47 ATH_MSG_DEBUG(
"Opening Collection '" << fileDescr.
PFN() <<
"' using container prefix: " << containerPrefix );
48 std::string tagContName = containerPrefix + "(";
49
50 std::set<std::string> seenContainers;
51 for( const Token *t : containerTokens ) {
52 Token token(t);
53 const std::string& contName =
db.cntName(token);
54 const DbTypeInfo* typ_info =
db.objectShape( token.classID() );
55 if( contName.starts_with( tagContName ) and !seenContainers.contains( contName ) ) {
56 seenContainers.insert( contName );
57 const std::string&
attrName = contName.substr( tagContName.size(), contName.size() - tagContName.size() - 1 );
58 ATH_MSG_DEBUG(
" :container " << contName <<
" with attribute " << attrName <<
" of type: " << typ_info->
clazz().
Name());
59 DbContainer
cnt(
db.type() );
60 if(
cnt.open( db, contName, typ_info, token.technology(),
db.openMode() ).isSuccess() ) {
62 const auto duplicate = std::find_if(
64 [&attrName]( const CollectionColumn& column ) {
65 return column.name() == attrName;
66 } );
68 throw std::runtime_error( "Column with name `" + attrName + "' already exists." );
69 }
71 }
73 } else {
74 ATH_MSG_WARNING(
"EventTag container " << contName <<
" could not be opened");
75 }
76 } else if( contName == newDHContName || contName == oldDHContName ) {
77 ATH_MSG_DEBUG(
" :container " << contName <<
" is the DataHeader container");
78 DbContainer
cnt(
db.type() );
79 if(
cnt.open( db, contName, typ_info, token.technology(),
db.openMode() ).isSuccess() ) {
81 } else {
82 ATH_MSG_WARNING(
"EventTag container " << contName <<
" could not be opened");
83 }
84 }
85 }
86}
#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::map< std::string, DbContainer > m_containerMap
Map of container names to container handles for all EventTag attributes in the file.
std::vector< CollectionColumn > m_attributeColumns
DbContainer m_dhCont
The DataHeader container, if present, in the file.
DbDatabaseObj * handle()
Access object identifier.
RootType clazz(bool noIdScan=false) const
Access to reflection class. If not known, by default scan all types for class ID.
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).
std::string Name(unsigned int mod=Reflex::SCOPED) const
std::string getDataHeaderName(std::string_view databaseName)
std::string getEventTagName(std::string_view databaseName)
static constexpr const char * DataHeaderTypeName