ATLAS Offline Software
Loading...
Searching...
No Matches
CollectionDescription.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef COLLECTIONSVC_COLLECTIONDESCRIPTION_H
6#define COLLECTIONSVC_COLLECTIONDESCRIPTION_H
7
8#include "StorageSvc/DbType.h"
9
10#include <map>
11#include <string>
12#include <vector>
13
14
15namespace pool {
16
17 class CollectionColumn;
18
26 {
27 public:
36 CollectionDescription( const std::string& name,
37 const DbType& type,
38 const std::string& connection = "" );
39
46
49
56
57 // Force the use of the user-defined copy operator (the default one leaks)
60
61 // Defaults should work for move.
63
69 void setName( const std::string& name );
70
76 void setType( const DbType& type );
77
83 void setConnection( const std::string& connection );
84
92 const std::string& columnName,
93 const std::string& columnType );
94
96 const std::string& name() const;
97
99 const DbType& type() const;
100
102 const std::string& connection() const;
103
107 static const CollectionColumn& tokenColumn() { return m_tokenColumn; }
108
113
120 const CollectionColumn& attributeColumn( int columnId ) const;
121
122 // set column ID, return the ID
123 int setColumnId( const std::string& columnName, int id );
124
125 protected:
126 // some helper methods for internal use:
127
129 void copyFrom( const CollectionDescription& rhs );
130
131 // clear all internal structures
132 void clearAll();
133
134 // set or assign new column ID
135 // return the ID
136 int setColumnId( pool::CollectionColumn *column, int id = -1 );
137
138 // rise an exception if the column aleready exists
139 void checkNewColumnName( const std::string& name ) const;
140
141 private:
143 std::string m_name;
144
147
149 std::string m_connection;
150
151 // Token column description object
153
155 std::vector< pool::CollectionColumn* > m_attributeColumns;
156
159 std::map< std::string, int > m_columnIdForColumnName;
160
161 typedef std::map< std::string, CollectionColumn* > ColumnByName;
164 };
165}
166
167#endif
An implementation for retrieving a description of a column of a collection.
CollectionDescription(const std::string &name, const DbType &type, const std::string &connection="")
Constructor that takes as input the minimum amount of properties needed to describe the collection.
const CollectionColumn & attributeColumn(int columnId) const
Returns a description object for an Attribute column of the collection, given the position of the col...
static const CollectionColumn & tokenColumn()
Returns a description object for the default Token column of the collection.
void setConnection(const std::string &connection)
Sets the connection to the database containing the collection.
const std::string & name() const
Returns the name of the collection and the top level collection fragment.
ColumnByName m_attributeColumnForColumnName
Map of Attribute CollectionColumn objects using column names as keys.
DbType m_type
Storage technology type of collection.
void checkNewColumnName(const std::string &name) const
std::string m_name
Name of the collection.
int numberOfAttributeColumns() const
Returns the number of Attribute columns in the collection.
void copyFrom(const CollectionDescription &rhs)
make this description a copy of 'rhs'
int setColumnId(const std::string &columnName, int id)
static const pool::CollectionColumn m_tokenColumn
std::map< std::string, int > m_columnIdForColumnName
Map of column ID numbers for column names IDs are unique in the collection.
void setName(const std::string &name)
Sets the name of the collection.
CollectionDescription(CollectionDescription &&)=default
void setType(const DbType &type)
Sets the storage technology type of the collection.
std::vector< pool::CollectionColumn * > m_attributeColumns
Attribute column description objects.
const DbType & type() const
Returns the storage technology type of the collection.
std::string m_connection
Connection to database containing collection.
std::map< std::string, CollectionColumn * > ColumnByName
const CollectionColumn & insertColumn(const std::string &columnName, const std::string &columnType)
Adds a new column to the collection.
int setColumnId(pool::CollectionColumn *column, int id=-1)
CollectionDescription(const CollectionDescription &rhs)
Copy constructor.
CollectionDescription & operator=(const CollectionDescription &rhs)
Assignment operator.
~CollectionDescription()
Default destructor.
const std::string & connection() const
Returns the connection to the database containing the collection.
pool namespace
Definition libname.h:15