ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Database
CoraCool
CoraCool
CoraCoolDatabase.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 CORACOOL_CORACOOLDATABASE_H
6
#define CORACOOL_CORACOOLDATABASE_H
7
// CoraCoolDatabase.h - interface to a CoraCool database instance
8
// for managing referenced payload data associated to a COOL database instance
9
// Richard Hawkings, started 10/06
10
11
#include<string>
12
#include "RelationalAccess/IConnectionService.h"
13
#include "CoralBase/MessageStream.h"
14
#include "CoolKernel/IDatabase.h"
15
#include "CoolKernel/IRecordSpecification.h"
16
#include "CoralBase/AttributeListSpecification.h"
17
#include "
CoraCool/CoraCoolTypes.h
"
18
19
namespace
coral
{
20
class
ISessionProxy;
21
class
ITable;
22
}
23
24
class
CoraCoolDatabase
{
25
public
:
26
// instantiate a new CoraCoolDatabase instance
27
// this should not normally be used - use openDatabase in CoraCoolDatabaseSvc
28
CoraCoolDatabase
(
const
std::string&
m_dbconn
, cool::IDatabasePtr cooldb,
29
coral::IConnectionService& coralsvc,
const
bool
readonly=
false
);
30
31
// connect to the underlying database, return true if connected
32
// users should not normally need to call this directly
33
bool
connect
();
34
// disconnect from the underlying database, returns false if disconnected
35
// users should not normally need to call this directly
36
bool
disconnect
();
37
38
// return the COOL database name associated with the folder
39
const
std::string&
dbname
()
const
;
40
41
// return the COOL database connection associated with the folder
42
cool::IDatabasePtr
coolDatabase
()
const
;
43
44
// create a CoraCool folder by creating the corresponding COOL folder and
45
// the CoraCool table with the given name (with COOL dbinstance prepended)
46
// the CoraCool metadata is added to the given descrpition string
47
// throws CoraCool and Cool exceptions in case of problems
48
CoraCoolFolderPtr
createFolder
(
const
std::string& coolpath,
49
const
std::string& coraltable,
50
const
cool::IRecordSpecification& fkspec,
51
const
cool::IRecordSpecification& payloadspec,
52
const
std::string& coralfk,
53
const
std::string& coralpk,
54
const
std::string&
description
=
""
,
55
const
cool::FolderVersioning::Mode mode=cool::FolderVersioning::SINGLE_VERSION,
56
const
bool
createParents=
false
);
57
58
// get a pointer to the CoraCoolFolder object
59
// throws CoraCool or Cool exceptions if folder does not exist, problems
60
// with <coracool> metadata etc
61
CoraCoolFolderPtr
getFolder
(
const
std::string& coolfolder);
62
63
// check if the folder exists as a CoraCool folder
64
// true if the corresponding COOL folder exists and there is the
65
// <coracool> meta data in the COOL description string
66
bool
existsFolder
(
const
std::string& coolfolder);
67
68
// parse the COOL folder description to extract the CORAL table name,
69
// COOL and CORAL foreign and primary key names
70
// returns true if all information extracted, false if syntax problems
71
bool
parseFolderDescription
(
const
std::string& folderdesc,
72
std::string& tablename,
73
std::string& keycolcool,
74
std::string& fkeycolcoral,
75
std::string& pkeycolcoral);
76
77
// delete the COOL folder and any associated CORAL table
78
// returns true if folder successfully dropped
79
// throws Cool or CoraCool exceptions if problems
80
bool
deleteFolder
(
const
std::string& coolfolder);
81
82
private
:
83
bool
extractCoralConStr
(std::string_view coolstr);
84
std::string
encodeAttrSpec
(
const
cool::IRecordSpecification& spec);
85
bool
storeSpec
(
const
std::string& tablename,
const
std::string& spec);
86
87
cool::IDatabasePtr
m_cooldb
;
// pointer to COOL database instance
88
std::string
m_dbconn
;
// CORAL database connection string
89
std::string
m_dbname
;
// COOL database instance name
90
bool
m_connected
;
// true when connection is active
91
bool
m_readonly
;
// true for readonly instance (can share connection)
92
coral::IConnectionService&
m_coralsvc
;
// CORAL connection service to use
93
coral::ISessionProxy*
m_proxy
;
94
coral::MessageStream
m_log
;
95
};
96
97
inline
const
std::string&
CoraCoolDatabase::dbname
()
const
{
return
m_dbname
; }
98
99
inline
cool::IDatabasePtr
CoraCoolDatabase::coolDatabase
()
const
100
{
return
m_cooldb
; }
101
102
#endif
// CORACOOL_CORACOOLDATABASE_H
CoraCoolTypes.h
CoraCoolFolderPtr
boost::shared_ptr< CoraCoolFolder > CoraCoolFolderPtr
Definition
CoraCoolTypes.h:16
CoraCoolDatabase::m_dbname
std::string m_dbname
Definition
CoraCoolDatabase.h:89
CoraCoolDatabase::m_coralsvc
coral::IConnectionService & m_coralsvc
Definition
CoraCoolDatabase.h:92
CoraCoolDatabase::createFolder
CoraCoolFolderPtr createFolder(const std::string &coolpath, const std::string &coraltable, const cool::IRecordSpecification &fkspec, const cool::IRecordSpecification &payloadspec, const std::string &coralfk, const std::string &coralpk, const std::string &description="", const cool::FolderVersioning::Mode mode=cool::FolderVersioning::SINGLE_VERSION, const bool createParents=false)
Definition
CoraCoolDatabase.cxx:199
CoraCoolDatabase::m_proxy
coral::ISessionProxy * m_proxy
Definition
CoraCoolDatabase.h:93
CoraCoolDatabase::m_log
coral::MessageStream m_log
Definition
CoraCoolDatabase.h:94
CoraCoolDatabase::m_dbconn
std::string m_dbconn
Definition
CoraCoolDatabase.h:88
CoraCoolDatabase::extractCoralConStr
bool extractCoralConStr(std::string_view coolstr)
Definition
CoraCoolDatabase.cxx:82
CoraCoolDatabase::CoraCoolDatabase
CoraCoolDatabase(const std::string &m_dbconn, cool::IDatabasePtr cooldb, coral::IConnectionService &coralsvc, const bool readonly=false)
Definition
CoraCoolDatabase.cxx:37
CoraCoolDatabase::connect
bool connect()
Definition
CoraCoolDatabase.cxx:58
CoraCoolDatabase::disconnect
bool disconnect()
Definition
CoraCoolDatabase.cxx:74
CoraCoolDatabase::deleteFolder
bool deleteFolder(const std::string &coolfolder)
Definition
CoraCoolDatabase.cxx:369
CoraCoolDatabase::getFolder
CoraCoolFolderPtr getFolder(const std::string &coolfolder)
Definition
CoraCoolDatabase.cxx:309
CoraCoolDatabase::dbname
const std::string & dbname() const
Definition
CoraCoolDatabase.h:97
CoraCoolDatabase::m_connected
bool m_connected
Definition
CoraCoolDatabase.h:90
CoraCoolDatabase::existsFolder
bool existsFolder(const std::string &coolfolder)
Definition
CoraCoolDatabase.cxx:316
CoraCoolDatabase::coolDatabase
cool::IDatabasePtr coolDatabase() const
Definition
CoraCoolDatabase.h:99
CoraCoolDatabase::m_cooldb
cool::IDatabasePtr m_cooldb
Definition
CoraCoolDatabase.h:87
CoraCoolDatabase::parseFolderDescription
bool parseFolderDescription(const std::string &folderdesc, std::string &tablename, std::string &keycolcool, std::string &fkeycolcoral, std::string &pkeycolcoral)
Definition
CoraCoolDatabase.cxx:330
CoraCoolDatabase::m_readonly
bool m_readonly
Definition
CoraCoolDatabase.h:91
CoraCoolDatabase::encodeAttrSpec
std::string encodeAttrSpec(const cool::IRecordSpecification &spec)
Definition
CoraCoolDatabase.cxx:138
CoraCoolDatabase::storeSpec
bool storeSpec(const std::string &tablename, const std::string &spec)
Definition
CoraCoolDatabase.cxx:152
description
std::string description
glabal timer - how long have I taken so far?
Definition
hcg.cxx:93
coral
Definition
ISecondaryEventSelector.h:19
Generated on
for ATLAS Offline Software by
1.17.0