ATLAS Offline Software
DbType.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //====================================================================
6 // DbType definition file
7 //--------------------------------------------------------------------
8 //
9 // Package : System (The pool framework)
10 //
11 // Description: Management of the object Databases
12 //
13 // @author M.Frank
14 //====================================================================
15 #ifndef POOL_DBTYPE_H
16 #define POOL_DBTYPE_H 1
17 
18 // Framework include files
19 #include <string>
20 
21 /*
22  * POOL namespace declaration
23  */
24 namespace pool {
25 
26  // Forward declarations
27  class DbPrint;
28 
31  class DbType {
32  private:
34  int m_type;
35  public:
37  static const constexpr unsigned int MASK = ~0x0;
39  static const int MINOR_MASK = 0xFF;
41  static const constexpr unsigned int MAJOR_MASK = MASK<<8;
42 
43  public:
45  DbType() : m_type(0) { }
47  DbType(int value) : m_type(value) { }
49  DbType(const DbType&) = default;
51  ~DbType() = default;
53  DbType& operator=(const DbType& typ) {
54  if ( this != &typ ) {
55  m_type = typ.type();
56  }
57  return *this;
58  }
60  bool operator==(const DbType& typ) const
61  { return (m_type&MAJOR_MASK) == (typ.type()&MAJOR_MASK); }
63  bool operator<(const DbType& typ) const
64  { return (m_type&MAJOR_MASK) < (typ.type()&MAJOR_MASK); }
66  int type() const { return m_type; }
68  int majorType() const { return type()&MAJOR_MASK; }
70  int minorType() const { return type()&MINOR_MASK; }
72  bool match(DbType typ) const { return type() == typ.type(); }
73  bool exactMatch(const DbType& typ) const { return majorType() == typ.majorType() and minorType() == typ.minorType(); }
75  void check() const;
77  const std::string storageName() const;
79  void missingDriver( DbPrint& str) const;
81  void badStorageType() const;
83  static DbType getType(const std::string& name);
84  };
85 
87  inline void DbType::check() const {
88  // Assume 0xF00 is biggest known mayor type
89  if ( majorType() == 0 || majorType() > 0xF00 ) {
91  }
92  }
93 
94  inline const DbType makeTechnology(int major_typ, int minor_typ)
95  { return ((major_typ<<8) + (DbType::MINOR_MASK&minor_typ)); }
96 
97  // Data storage technique identifiers
98  static const DbType TEST_StorageType = makeTechnology(0,0);
99  static const DbType POOL_StorageType = makeTechnology(1,0);
100  static const DbType ROOT_StorageType = makeTechnology(2,0);
101  static const DbType ROOTKEY_StorageType = makeTechnology(2,1);
102  static const DbType ROOTTREE_StorageType = makeTechnology(2,2);
103  static const DbType ROOTTREEINDEX_StorageType = makeTechnology(2,3);
104  static const DbType ROOTRNTUPLE_StorageType = makeTechnology(2,5);
105  static const DbType OBJY_StorageType = makeTechnology(3,0);
106  static const DbType ACCESS_StorageType = makeTechnology(4,0);
107  static const DbType EXCEL_StorageType = makeTechnology(5,0);
108  static const DbType TEXTJET_StorageType = makeTechnology(6,0);
109  static const DbType SQLSERVER_StorageType = makeTechnology(7,0);
110  static const DbType MYSQL_StorageType = makeTechnology(8,0);
111  static const DbType ORACLE_StorageType = makeTechnology(9,0);
112  static const DbType XML_StorageType = makeTechnology(10,0);
113 
114  static const DbType POOL_RDBMS_StorageType = makeTechnology(11,0);
115  static const DbType POOL_RDBMS_HOMOGENEOUS_StorageType = makeTechnology(11,1);
116  static const DbType POOL_RDBMS_POLYMORPHIC_StorageType = makeTechnology(11,2);
117 
118 } // End namespace pool
119 #endif // POOL_DBTYPE_H
pool::DbType::storageName
const std::string storageName() const
Human readable storage type.
pool::DbPrint
Definition: DbPrint.h:37
pool::DbType::getType
static DbType getType(const std::string &name)
Access known storage type object by name.
pool::DbType::DbType
DbType()
Standard constructor.
Definition: DbType.h:45
pool::DbType::operator=
DbType & operator=(const DbType &typ)
Assignment operator.
Definition: DbType.h:53
pool
pool namespace
Definition: libname.h:15
athena.value
value
Definition: athena.py:122
pool::DbType::MAJOR_MASK
static constexpr const unsigned int MAJOR_MASK
MAJOR type mask (3 high bytes set)
Definition: DbType.h:41
pool::makeTechnology
const DbType makeTechnology(int major_typ, int minor_typ)
Definition: DbType.h:94
pool::DbType::check
void check() const
Check if type is within allowed range.
Definition: DbType.h:87
pool::DbType::type
int type() const
Access to full type.
Definition: DbType.h:66
pool::DbType::MINOR_MASK
static const int MINOR_MASK
MINOR type mask (1 low byte set)
Definition: DbType.h:39
pool::DbType
Definition: DbType.h:31
pool::DbType::DbType
DbType(int value)
Constructor with initializer from.
Definition: DbType.h:47
pool::DbType::missingDriver
void missingDriver(DbPrint &str) const
Error message on missing back-end driver implementation.
pool::DbType::m_type
int m_type
Database type.
Definition: DbType.h:34
pool::DbType::DbType
DbType(const DbType &)=default
Default copy constructor.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
pool::DbType::minorType
int minorType() const
Access to minor type.
Definition: DbType.h:70
pool::DbType::majorType
int majorType() const
Access to major type.
Definition: DbType.h:68
pool::DbType::operator<
bool operator<(const DbType &typ) const
Operator less.
Definition: DbType.h:63
pool::DbType::~DbType
~DbType()=default
Standard destructor.
pool::DbType::exactMatch
bool exactMatch(const DbType &typ) const
Definition: DbType.h:73
pool::DbType::match
bool match(DbType typ) const
Check if types match.
Definition: DbType.h:72
pool::DbType::MASK
static constexpr const unsigned int MASK
MASK: all bits set (All bits set)
Definition: DbType.h:37
str
Definition: BTagTrackIpAccessor.cxx:11
pool::DbType::operator==
bool operator==(const DbType &typ) const
Equal operator.
Definition: DbType.h:60
pool::DbType::badStorageType
void badStorageType() const
Error processing on bad storage type.