EIC Software
Reference for
EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
FairParTSQLIo.cxx
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file FairParTSQLIo.cxx
1
/***************************************
2
* Author: M.Babai (M.Babai@rug.nl) *
3
* License: *
4
* Version: *
5
***************************************/
6
#include "
FairParTSQLIo.h
"
7
8
9
#include "
FairGenericParTSQLIo.h
"
10
#include "
FairDbMultConnector.h
"
11
12
ClassImp
(
FairParTSQLIo
)
13
14
17
FairParTSQLIo
::
FairParTSQLIo
()
18
:
FairParIo
(),
19
fDefaultDb (-1),
20
fConnections( new
FairDbMultConnector
() )
21
{
22
std::cout <<
"\t<DEBUG_INFO>FairParTSQLIo::FairParTSQLIo()\n"
;
23
}
24
31
FairParTSQLIo::FairParTSQLIo
(
FairDbMultConnector
const
& cons,
int
const
dbNum)
32
:
FairParIo
(),
33
fDefaultDb (dbNum),
34
fConnections(new
FairDbMultConnector
(cons))
35
{
36
std::cout <<
"\t<DEBUG_INFO>FairParTSQLIo::FairParTSQLIo()12\n"
;
37
}
38
42
FairParTSQLIo::~FairParTSQLIo
()
43
{
44
disconnect
();
45
}
46
50
bool
FairParTSQLIo::check
()
51
{
52
//FairDbMultConnector::Status s;
53
int
stat = -100;
54
// Check if at least one DB is connected.
55
if
(
fDefaultDb
!= -1) {
// Has been specified.
56
stat =
fConnections
->
GetStatus
(
fDefaultDb
);
57
if
(stat ==
FairDbMultConnector::kFailed
||
58
stat ==
FairDbMultConnector::kClosed
)
59
std::cerr <<
"<Error> The connection to specified default Database"
60
<<
" is not alive.\n"
;
61
}
else
{
// No selection
62
for
(
size_t
db
= 0;
db
<
fConnections
->
GetNumDb
(); ++
db
) {
63
stat =
fConnections
->
GetStatus
(
db
);
64
}
65
}
66
return
kTRUE;
67
//return ( stat == FairDbMultConnector::kOpen);
68
}
69
74
void
FairParTSQLIo::setDetParIo
(Text_t* ioName)
75
{
76
if
(
fConnections
) {
77
TObject
* io =
detParIoList
->FindObject(ioName);
78
// If does not exist
79
if
(!io) {
80
if
(strcmp(ioName,
"FairGenericParIo"
) == 0) {
81
io =
new
FairGenericParTSQLIo
();
82
}
83
if
(io) {
84
detParIoList
->Add(io);
85
}
86
}
87
}
88
}
89
93
void
FairParTSQLIo::disconnect
()
94
{
95
if
(
fConnections
) {
96
std::cout <<
"\n\t<DEBUG> Terminating connection and status = "
97
<<
fConnections
->
GetStatusAsString
(0)
98
<<
"\n\n"
;
99
delete
fConnections
;
100
fConnections
= 0;
101
}
102
}
103
104
bool
FairParTSQLIo::activateDetIo
()
105
{
106
std::cout <<
"<DEBUG> FairParTSQLIo::activateDetIo()\n"
;
107
// FIXME FIXME Maybe better to call check first
108
if
(!
fConnections
) {
109
return
false
;
110
}
111
FairDetParIo
* io=
new
FairGenericParTSQLIo
();
112
detParIoList
->Add(io);
113
return
true
;
114
}
115
121
bool
FairParTSQLIo::open
()
122
{
123
std::cout <<
"<DEBUG> FairParTSQLIo::open()\n"
;
124
return
activateDetIo
();
125
}
126
130
void
FairParTSQLIo::print
()
131
{
132
std::cout <<
"<DEBUG> FairParTSQLIo::print()\n"
;
133
if
(
fConnections
) {
134
std::cout <<
"<INFO> Number of available DBs = "
<<
fConnections
->
GetNumDb
()
135
<< std::endl;
136
137
TIter next(
detParIoList
);
138
FairDetParIo
* io;
139
std::cout <<
" Number of detector I/Os = "
<<
detParIoList
->GetSize()
140
<<
"\nDetector IO list:\n"
;
141
142
while
((io=(
FairDetParIo
*)next())) {
143
std::cout<<
" Name = "
<< io->GetName();
144
}
//while
145
std::cout << std::endl;
146
}
//if
147
}
//print
EicRoot
blob
master
parbase
dbIO
FairParTSQLIo.cxx
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:36
using
1.8.2 with
EIC GitHub integration