ATLAS Offline Software
CollectionDescription.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef COLLECTIONBASE_COLLECTIONDESCRIPTION_H
6 #define COLLECTIONBASE_COLLECTIONDESCRIPTION_H
7 
10 
11 #include <map>
12 
13 
14 namespace pool {
15 
16  class CollectionColumn;
17  class CollectionIndex;
18 
28  virtual public ICollectionSchemaEditor
29  {
30  public:
42  CollectionDescription( const std::string& name,
43  const std::string& type,
44  const std::string& connection = "",
45  const std::string& eventReferenceColumnName = "" );
46 
54 
57 
64 
71  { operator=( (const ICollectionDescription&) rhs ); return *this; }
72 
78  bool operator==( const CollectionDescription& rhs ) const;
79 
85  bool operator!=( const CollectionDescription& rhs ) const;
86 
92  virtual bool equals( const ICollectionDescription& rhs ) const;
93 
100  virtual bool isSubsetOf( const ICollectionDescription& rhs ) const;
101 
107  virtual void setName( const std::string& name );
108 
114  virtual void setType( const std::string& type );
115 
121  virtual void setConnection( const std::string& connection );
122 
128  virtual void setEventReferenceColumnName( const std::string& columnName );
129 
139  const std::string& columnName,
140  const std::string& columnType,
141  const std::string& annotation = "",
142  int maxSize = 0,
143  bool sizeIsFixed = true );
144 
154  const std::string& columnName,
155  const std::type_info& columnType,
156  const std::string& annotation = "",
157  int maxSize = 0,
158  bool sizeIsFixed = true );
159 
166  const std::string& columnName,
167  const std::string& annotation = "");
168 
169 
172  const std::string& columnName,
173  const std::string& annotation );
174 
175 
181  virtual void dropColumn( const std::string& columnName );
182 
189  virtual void renameColumn( const std::string& oldName, const std::string& newName );
190 
200  virtual void changeColumnType( const std::string& columnName,
201  const std::string& newType,
202  int maxSize = 0,
203  bool sizeIsFixed = true );
204 
214  virtual void changeColumnType( const std::string& columnName,
215  const std::type_info& newType,
216  int maxSize = 0,
217  bool sizeIsFixed = true );
218 
226  virtual void createIndex( std::string indexName, const std::string& columnName, bool isUnique = false );
227 
235  virtual void createIndex( std::string indexName, const std::vector< std::string >& columnNames, bool isUnique = false );
236 
243  virtual void dropIndex( const std::string& columnName );
244 
251  virtual void dropIndex( const std::vector<std::string>& columnNames );
252 
253 
255  virtual const std::string& name() const;
256 
258  virtual const std::string& type() const;
259 
261  virtual const std::string& connection() const;
262 
267  virtual const std::string& eventReferenceColumnName() const;
268 
273  virtual bool hasEventReferenceColumn() const;
274 
279  virtual int numberOfColumns() const;
280 
287  virtual const ICollectionColumn& column( const std::string& columnName ) const;
288 
290  virtual const ICollectionColumn* columnPtr( const std::string& columnName ) const;
291 
295  virtual int numberOfTokenColumns() const;
296 
303  virtual const ICollectionColumn& tokenColumn( const std::string& columnName ) const;
304 
311  virtual const ICollectionColumn& tokenColumn( int columnId ) const;
312 
316  virtual int numberOfAttributeColumns() const;
317 
324  virtual const ICollectionColumn& attributeColumn( const std::string& columnName ) const;
325 
332  virtual const ICollectionColumn& attributeColumn( int columnId ) const;
333 
335  const std::vector< pool::CollectionColumn* >& tokenColumns() const { return m_tokenColumns; }
336 
338  const std::vector< pool::CollectionColumn* >& attributeColumns() const { return m_attributeColumns; }
339 
343  virtual int numberOfIndices() const;
344 
351  virtual const ICollectionIndex& index( const std::string& columnName ) const;
352 
359  virtual const ICollectionIndex& index( const std::vector<std::string>& columnNames ) const;
360 
367  virtual const ICollectionIndex& index( int indexId ) const;
368 
369  // set column ID, return the ID
370  virtual int setColumnId( const std::string& columnName, int id, const std::string& methodName );
371 
372  protected:
373  // some helper methods for internal use:
374 
376  virtual void copyFrom( const ICollectionDescription& rhs );
377 
378  // clear all internal structures
379  virtual void clearAll();
380 
381  // set or assign new column ID
382  // return the ID
383  virtual int setColumnId( pool::CollectionColumn *column, int id = -1 );
384 
385  // rise an exception if the column aleready exists
386  virtual void checkNewColumnName( const std::string& name, const std::string& method ) const;
387 
388  // check if the column contains tokens
389  virtual bool isTokenColumn( const std::string& columnName, const std::string& method ) const;
390 
391  // this version includes the 'method name' in the error message
392  virtual pool::CollectionColumn* column( const std::string& columnName, const std::string& methodName );
393  virtual const pool::CollectionColumn* column( const std::string& columnName, const std::string& methodName ) const;
394 
395  public:
397  virtual void printOut() const;
398 
399 
400  private:
402  std::string m_name;
403 
405  std::string m_type;
406 
408  std::string m_connection;
409 
412 
413  // Token column description objects
414  std::vector< pool::CollectionColumn* > m_tokenColumns;
415 
417  std::vector< pool::CollectionColumn* > m_attributeColumns;
418 
421  std::map< std::string, int > m_columnIdForColumnName;
422 
423  typedef std::map< std::string, CollectionColumn* > ColumnByName;
426 
429 
431  std::vector< CollectionIndex* > m_indices;
432  };
433 }
434 
435 #endif
436 
RunTileTBRec.method
method
Definition: RunTileTBRec.py:73
pool::CollectionDescription::insertColumn
virtual const ICollectionColumn & insertColumn(const std::string &columnName, const std::string &columnType, const std::string &annotation="", int maxSize=0, bool sizeIsFixed=true)
Adds a new column to the collection.
pool::CollectionDescription::column
virtual const ICollectionColumn & column(const std::string &columnName) const
Returns a description object for a column of the collection, given the name of the column.
pool::CollectionDescription::m_tokenColumns
std::vector< pool::CollectionColumn * > m_tokenColumns
Definition: CollectionDescription.h:414
pool::CollectionDescription::m_indices
std::vector< CollectionIndex * > m_indices
Vector of CollectionIndex objects.
Definition: CollectionDescription.h:431
pool::CollectionDescription::dropIndex
virtual void dropIndex(const std::string &columnName)
Removes an index from the collection description, given the name of the column on which the index to ...
pool::CollectionDescription::setConnection
virtual void setConnection(const std::string &connection)
Sets the connection to the database containing the collection.
pool::CollectionDescription::insertTokenColumn
virtual const ICollectionColumn & insertTokenColumn(const std::string &columnName, const std::string &annotation="")
Adds a new column of type pool::Token to the collection.
pool::CollectionDescription::index
virtual const ICollectionIndex & index(const std::string &columnName) const
Returns a description object for an index of the collection, given the name of the column on which th...
pool::CollectionDescription::m_connection
std::string m_connection
Connection to database containing collection.
Definition: CollectionDescription.h:408
pool::CollectionDescription::dropColumn
virtual void dropColumn(const std::string &columnName)
Removes a column from the collection description.
pool::ICollectionSchemaEditor
Definition: ICollectionSchemaEditor.h:22
pool::CollectionDescription::changeColumnType
virtual void changeColumnType(const std::string &columnName, const std::string &newType, int maxSize=0, bool sizeIsFixed=true)
Changes the data type of a column in the collection description.
pool
pool namespace
Definition: libname.h:15
pool::CollectionDescription::index
virtual const ICollectionIndex & index(int indexId) const
Returns a description object for an index of the collection, given the ID number of the index.
pool::CollectionDescription::createIndex
virtual void createIndex(std::string indexName, const std::string &columnName, bool isUnique=false)
Creates an index on a column of the collection description.
pool::CollectionDescription::attributeColumn
virtual const ICollectionColumn & attributeColumn(const std::string &columnName) const
Returns a description object for an Attribute column of the collection, given the name of the column.
pool::CollectionDescription::name
virtual const std::string & name() const
Returns the name of the collection and the top level collection fragment.
pool::CollectionDescription::m_name
std::string m_name
Name of the collection.
Definition: CollectionDescription.h:402
pool::CollectionDescription::hasEventReferenceColumn
virtual bool hasEventReferenceColumn() const
Indicates whether the top level collection fragment contains the event reference column and is theref...
pool::CollectionDescription::column
virtual const pool::CollectionColumn * column(const std::string &columnName, const std::string &methodName) const
pool::CollectionDescription::tokenColumn
virtual const ICollectionColumn & tokenColumn(const std::string &columnName) const
Returns a description object for a Token column of the collection, given the name of the column.
pool::CollectionDescription::operator=
CollectionDescription & operator=(const ICollectionDescription &rhs)
Assignment operator.
pool::CollectionDescription::m_columnIdForColumnName
std::map< std::string, int > m_columnIdForColumnName
Map of column ID numbers for column names IDs are unique in the collection.
Definition: CollectionDescription.h:421
pool::CollectionDescription::setEventReferenceColumnName
virtual void setEventReferenceColumnName(const std::string &columnName)
Sets the name of the event reference Token column.
pool::CollectionDescription::insertColumn
virtual const ICollectionColumn & insertColumn(const std::string &columnName, const std::type_info &columnType, const std::string &annotation="", int maxSize=0, bool sizeIsFixed=true)
Adds a new column to the collection.
pool::CollectionDescription::isTokenColumn
virtual bool isTokenColumn(const std::string &columnName, const std::string &method) const
pool::CollectionDescription::annotateColumn
virtual const ICollectionColumn & annotateColumn(const std::string &columnName, const std::string &annotation)
add annotation to column
pool::CollectionDescription::tokenColumns
const std::vector< pool::CollectionColumn * > & tokenColumns() const
Returns the Token column description objects.
Definition: CollectionDescription.h:335
pool::CollectionDescription::CollectionDescription
CollectionDescription(const std::string &name, const std::string &type, const std::string &connection="", const std::string &eventReferenceColumnName="")
Constructor that takes as input the minimum amount of properties needed to describe the collection.
ICollectionSchemaEditor.h
pool::CollectionDescription::m_attributeColumns
std::vector< pool::CollectionColumn * > m_attributeColumns
Attribute column description objects.
Definition: CollectionDescription.h:417
pool::CollectionDescription::numberOfColumns
virtual int numberOfColumns() const
Returns the number of columns (including the event reference column if it is used) in the collection.
pool::CollectionDescription::eventReferenceColumnName
virtual const std::string & eventReferenceColumnName() const
Returns the name reserved for the event reference Token column.
pool::CollectionDescription::operator=
CollectionDescription & operator=(const CollectionDescription &rhs)
Assignment operator.
Definition: CollectionDescription.h:70
pool::CollectionDescription::setColumnId
virtual int setColumnId(const std::string &columnName, int id, const std::string &methodName)
pool::CollectionDescription::m_tokenColumnForColumnName
ColumnByName m_tokenColumnForColumnName
Map of Token CollectionColumn objects using column names as keys.
Definition: CollectionDescription.h:425
pool::CollectionDescription
Definition: CollectionDescription.h:29
pool::CollectionColumn
Definition: CollectionColumn.h:24
pool::CollectionDescription::operator!=
bool operator!=(const CollectionDescription &rhs) const
Inequality operator.
pool::CollectionDescription::CollectionDescription
CollectionDescription(const CollectionDescription &rhs)
pool::CollectionDescription::numberOfIndices
virtual int numberOfIndices() const
Returns the number of indices used by the collection.
pool::ICollectionColumn
Definition: ICollectionColumn.h:19
pool::CollectionDescription::attributeColumn
virtual const ICollectionColumn & attributeColumn(int columnId) const
Returns a description object for an Attribute column of the collection, given the position of the col...
pool::CollectionDescription::printOut
virtual void printOut() const
print out the description (debugging)
pool::CollectionDescription::connection
virtual const std::string & connection() const
Returns the connection to the database containing the collection.
pool::CollectionDescription::checkNewColumnName
virtual void checkNewColumnName(const std::string &name, const std::string &method) const
pool::CollectionDescription::clearAll
virtual void clearAll()
pool::CollectionDescription::setType
virtual void setType(const std::string &type)
Sets the storage technology type of the collection.
MakeNewFileFromOldAndSubstitution.newName
dictionary newName
Definition: ICHEP2016/MakeNewFileFromOldAndSubstitution.py:95
pool::CollectionDescription::columnPtr
virtual const ICollectionColumn * columnPtr(const std::string &columnName) const
return pointer to Column or NULL if it's not found (will not throw exceptions)
pool::CollectionDescription::m_eventReferenceColumnName
std::string m_eventReferenceColumnName
Name of event reference column.
Definition: CollectionDescription.h:411
pool::CollectionDescription::attributeColumns
const std::vector< pool::CollectionColumn * > & attributeColumns() const
Returns the Attribute column description objects.
Definition: CollectionDescription.h:338
pool::CollectionDescription::index
virtual const ICollectionIndex & index(const std::vector< std::string > &columnNames) const
Returns a description object for an index of the collection, given the names of the columns on which ...
pool::CollectionDescription::numberOfTokenColumns
virtual int numberOfTokenColumns() const
Returns the number of Token columns (including the event reference column if it is used)
pool::CollectionDescription::changeColumnType
virtual void changeColumnType(const std::string &columnName, const std::type_info &newType, int maxSize=0, bool sizeIsFixed=true)
Changes the data type of a column in the collection description.
pool::CollectionDescription::column
virtual pool::CollectionColumn * column(const std::string &columnName, const std::string &methodName)
pool::CollectionDescription::m_attributeColumnForColumnName
ColumnByName m_attributeColumnForColumnName
Map of Attribute CollectionColumn objects using column names as keys.
Definition: CollectionDescription.h:428
pool::CollectionDescription::setName
virtual void setName(const std::string &name)
Sets the name of the collection.
pool::ICollectionIndex
Definition: ICollectionIndex.h:20
pool::CollectionDescription::tokenColumn
virtual const ICollectionColumn & tokenColumn(int columnId) const
Returns a description object for a Token column of the collection, given the position of the column.
pool::CollectionDescription::numberOfAttributeColumns
virtual int numberOfAttributeColumns() const
Returns the number of Attribute columns in the collection.
pool::CollectionDescription::copyFrom
virtual void copyFrom(const ICollectionDescription &rhs)
make this description a copy of 'rhs'
pool::CollectionDescription::equals
virtual bool equals(const ICollectionDescription &rhs) const
Check if both Descriptions have the same columns.
pool::CollectionDescription::createIndex
virtual void createIndex(std::string indexName, const std::vector< std::string > &columnNames, bool isUnique=false)
Creates an index on one or more columns of the collection description.
pool::CollectionDescription::type
virtual const std::string & type() const
Returns the storage technology type of the collection.
ICollectionDescription.h
pool::CollectionDescription::operator==
bool operator==(const CollectionDescription &rhs) const
Equality operator.
pool::CollectionDescription::isSubsetOf
virtual bool isSubsetOf(const ICollectionDescription &rhs) const
Check if all columns from this Description are present in the rhs Description and if they have the sa...
pool::CollectionDescription::renameColumn
virtual void renameColumn(const std::string &oldName, const std::string &newName)
Renames a column of the collection description.
pool::CollectionDescription::ColumnByName
std::map< std::string, CollectionColumn * > ColumnByName
Definition: CollectionDescription.h:423
pool::CollectionDescription::~CollectionDescription
virtual ~CollectionDescription()
Default destructor.
pool::CollectionDescription::m_type
std::string m_type
Storage technology type of collection.
Definition: CollectionDescription.h:405
pool::ICollectionDescription
Definition: ICollectionDescription.h:26
pool::CollectionDescription::CollectionDescription
CollectionDescription(const ICollectionDescription &rhs)
Copy constructor.
pool::CollectionDescription::dropIndex
virtual void dropIndex(const std::vector< std::string > &columnNames)
Removes an index from a column of the collection description, given the names of the columns on which...
pool::CollectionDescription::setColumnId
virtual int setColumnId(pool::CollectionColumn *column, int id=-1)