ATLAS Offline Software
CollectionColumn.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_COLLECTIONCOLUMN_H
6 #define COLLECTIONBASE_COLLECTIONCOLUMN_H
7 
9 
10 #include "CoralBase/AttributeSpecification.h"
11 
12 #include <typeinfo>
13 
14 
15 namespace pool {
16 
24  {
25  public:
28  : m_name( "" ),
29  m_type( "" ),
30  m_maxSize( 0 ),
31  m_sizeIsFixed( true ),
32  m_id( 0 ) {}
33 
42  CollectionColumn( const std::string& name,
43  const std::string& type,
44  int maxSize = 0,
45  bool sizeIsFixed = true )
46  : m_name( name ),
47  m_type( type ),
48  m_maxSize( maxSize ),
50  m_id( 0 ) {}
51 
55  m_name( rhs.m_name ),
56  m_type( rhs.m_type ),
57  m_maxSize( rhs.m_maxSize ),
59  m_id( rhs.m_id )
60  {}
61 
64 
67  {
68  m_name = rhs.m_name;
69  m_type = rhs.m_type;
70  m_maxSize = rhs.m_maxSize;
72  m_id = rhs.m_id;
73 
74  return *this;
75  }
76 
78  bool operator==( const CollectionColumn& rhs ) const
79  {
80  return
81  m_name == rhs.m_name &&
82  m_type == rhs.m_type &&
83  m_maxSize == rhs.m_maxSize &&
85  // && m_id == rhs.m_id //MN - does not matter?
86  ;
87  }
88 
90  bool operator!=( const CollectionColumn& rhs ) const
91  {
92  return !( *this == rhs );
93  }
94 
100  virtual void setName( const std::string& name ) { m_name = name; }
101 
107  virtual void setType( const std::string& type ) { m_type = type; }
108 
114  virtual void setType( const std::type_info& type )
115  { m_type = coral::AttributeSpecification::typeNameForId( type ); }
116 
123  virtual void setMaxSize( int maxSize ) { m_maxSize = maxSize; }
124 
132 
134  virtual void setId( int id ) { m_id = id; }
135 
137  virtual void setAnnotation( const std::string& anno ) { m_annotation = anno; }
138 
140  virtual const std::string& name() const { return m_name; }
141 
143  virtual const std::string& type() const { return m_type; }
144 
146  virtual const std::string& annotation() const { return m_annotation; }
147 
152  virtual int maxSize() const { return m_maxSize; }
153 
158  virtual bool sizeIsFixed() const { return m_sizeIsFixed; }
159 
161  virtual int id() const { return m_id; }
162 
163  private:
165  std::string m_name;
166 
168  std::string m_type;
169 
171  std::string m_annotation;
172 
173 
176 
179 
181  int m_id;
182  };
183 
184 }
185 
186 #endif
187 
188 
pool::CollectionColumn::setName
virtual void setName(const std::string &name)
Sets the name of the column.
Definition: CollectionColumn.h:100
pool::CollectionColumn::setType
virtual void setType(const std::string &type)
Sets the data type of the column.
Definition: CollectionColumn.h:107
pool::CollectionColumn::m_sizeIsFixed
bool m_sizeIsFixed
Flag indicating whether data type of column can vary in size.
Definition: CollectionColumn.h:178
ICollectionColumn.h
pool
pool namespace
Definition: libname.h:15
pool::CollectionColumn::CollectionColumn
CollectionColumn(const CollectionColumn &rhs)
Copy constructor.
Definition: CollectionColumn.h:53
pool::CollectionColumn::name
virtual const std::string & name() const
Returns the name of the column.
Definition: CollectionColumn.h:140
pool::CollectionColumn::CollectionColumn
CollectionColumn(const std::string &name, const std::string &type, int maxSize=0, bool sizeIsFixed=true)
Constructor that takes the column properties as input.
Definition: CollectionColumn.h:42
pool::CollectionColumn::CollectionColumn
CollectionColumn()
Default constructor.
Definition: CollectionColumn.h:27
pool::CollectionColumn::setType
virtual void setType(const std::type_info &type)
Sets the data type of the column.
Definition: CollectionColumn.h:114
pool::CollectionColumn::sizeIsFixed
virtual bool sizeIsFixed() const
Indicates whether the data type of the column can vary in size.
Definition: CollectionColumn.h:158
pool::CollectionColumn::annotation
virtual const std::string & annotation() const
Returns the user annotation for this column.
Definition: CollectionColumn.h:146
pool::CollectionColumn::m_maxSize
int m_maxSize
Maximum size of column data type.
Definition: CollectionColumn.h:175
pool::CollectionColumn::setAnnotation
virtual void setAnnotation(const std::string &anno)
Returns the user annotation for this column.
Definition: CollectionColumn.h:137
pool::CollectionColumn::m_annotation
std::string m_annotation
User annotation.
Definition: CollectionColumn.h:171
pool::CollectionColumn
Definition: CollectionColumn.h:24
pool::CollectionColumn::operator==
bool operator==(const CollectionColumn &rhs) const
Equality operator.
Definition: CollectionColumn.h:78
pool::CollectionColumn::~CollectionColumn
~CollectionColumn()
Default destructor.
Definition: CollectionColumn.h:63
pool::ICollectionColumn
Definition: ICollectionColumn.h:19
pool::CollectionColumn::operator!=
bool operator!=(const CollectionColumn &rhs) const
Inequality operator.
Definition: CollectionColumn.h:90
pool::CollectionColumn::setMaxSize
virtual void setMaxSize(int maxSize)
Sets the maximum size of the column data type.
Definition: CollectionColumn.h:123
pool::CollectionColumn::m_id
int m_id
Position of column in associated collection fragment.
Definition: CollectionColumn.h:181
pool::CollectionColumn::m_name
std::string m_name
Name of column.
Definition: CollectionColumn.h:165
pool::CollectionColumn::setId
virtual void setId(int id)
Sets the position of the column in its associated collection fragment.
Definition: CollectionColumn.h:134
pool::CollectionColumn::m_type
std::string m_type
Data type of column.
Definition: CollectionColumn.h:168
pool::CollectionColumn::maxSize
virtual int maxSize() const
Returns the maximum size of the column data type.
Definition: CollectionColumn.h:152
pool::CollectionColumn::operator=
CollectionColumn & operator=(const CollectionColumn &rhs)
Assignment operator.
Definition: CollectionColumn.h:66
pool::CollectionColumn::id
virtual int id() const
Returns the position of the column in its associated collection fragment.
Definition: CollectionColumn.h:161
pool::CollectionColumn::setSizeIsFixed
virtual void setSizeIsFixed(bool sizeIsFixed)
Sets a flag indicating whether the size of the column data type may vary.
Definition: CollectionColumn.h:131
pool::CollectionColumn::type
virtual const std::string & type() const
Returns the data type of the column.
Definition: CollectionColumn.h:143