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
FairDbConfDialog.cxx
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file FairDbConfDialog.cxx
1
#include <iostream>
2
#include "
FairDbConfDialog.h
"
3
4
//......................................................................
5
6
FairDbConfDialog::FairDbConfDialog
() :
7
fCurrent(),
8
fDefault(),
9
fResult()
10
{ }
11
12
//......................................................................
13
14
FairDbConfDialog::FairDbConfDialog
(
const
FairRegistry
& cur,
const
FairRegistry
& defl) :
15
fCurrent(cur),
16
fDefault(defl),
17
fResult()
18
{ }
19
20
//......................................................................
21
22
FairDbConfDialog::~FairDbConfDialog
() { }
23
24
//......................................................................
25
26
void
FairDbConfDialog::SetCurrent
(
const
FairRegistry
& r)
27
{
28
//======================================================================
29
// Copy the registry r to the set of values to display as current
30
// values
31
//======================================================================
32
fCurrent
.
UnLockValues
();
33
fCurrent
= r;
34
fCurrent
.
LockValues
();
35
}
36
37
//......................................................................
38
39
void
FairDbConfDialog::SetDefault
(
const
FairRegistry
& r)
40
{
41
//======================================================================
42
// Copy the registry r to the set of values to display as default values
43
//======================================================================
44
fDefault
.
UnLockValues
();
45
fDefault
= r;
46
fCurrent
.
LockValues
();
47
}
48
49
//......................................................................
50
51
FairRegistry
&
FairDbConfDialog::Query
()
52
{
53
//======================================================================
54
// Conduct the dialog with the user to load new values into the
55
// registry. Return the registry stuffed with the new values.
56
//======================================================================
57
FairRegistry::FairRegistryKey
rk =
fCurrent
.
Key
();
58
59
// Setup result registry
60
fResult
=
fCurrent
;
61
fResult
.
UnLockValues
();
62
63
const
char
*
k
;
// Key name
64
while
( (k=rk()) ) {
65
// bool b; // Temp. bool value
66
char
c
;
// Temp. char value
67
const
char
*
s
;
// Temp. string value
68
int
i;
// Temp. int value
69
double
d
;
// Temp. double value
70
FairRegistry
r;
// Temp. FairRegistry value
71
72
// Use the 'current' registry to divine the types of junk...
73
// Currently there's no good way to do this and FairRegistry spits
74
// warnings at you for even trying...
75
bool
isBool =
false
;
76
// bool isBool = fDefault.Get(k, b);
77
bool
isChar =
fDefault
.
Get
(k, c);
78
bool
isString =
fDefault
.
Get
(k, s);
79
bool
isInt =
fDefault
.
Get
(k, i);
80
bool
isDouble =
fDefault
.
Get
(k, d);
81
bool
isFairRegistry =
false
;
82
// bool isFairRegistry = fCurrent.Get(k, r);
83
84
#define PROMPT(t,c,d) \
85
std::cout << " "<<t<<" "<<k<<" = ["<<d<<"] "<<c<<" =? ";
86
// OK, now get the user's input. One "if" per type...
87
if
(isBool) {
88
// bool b1, b_in;
89
// fDefault.Get(k, b1);
90
// PROMPT("bool",b,b1);
91
// std::cin >> b_in;
92
// fResult.Set(k, d_in);
93
}
else
if
(isChar) {
94
char
c1
, c_in;
95
fDefault
.
Get
(k, c1);
96
PROMPT
(
"char"
,c,c1);
97
std::cin >> c_in;
98
fResult
.
Set
(k, c_in);
99
}
else
if
(isString) {
100
const
char
*
s1
;
101
std::string s_in;
102
fDefault
.
Get
(k, s1);
103
PROMPT
(
"string"
,s,s1);
104
std::cin >> s_in;
105
// This is OK, FairRegistry allocates space and stores a copy
106
// of the string, not just the pointer
107
fResult
.
Set
(k, s_in.c_str());
108
}
else
if
(isInt) {
109
int
i1, i_in;
110
fDefault
.
Get
(k, i1);
111
PROMPT
(
"int"
,i,i1);
112
std::cin >> i_in;
113
fResult
.
Set
(k, i_in);
114
}
else
if
(isDouble) {
115
double
d1, d_in;
116
fDefault
.
Get
(k, d1);
117
PROMPT
(
"double"
,d,d1);
118
std::cin >> d_in;
119
fResult
.
Set
(k, d_in);
120
}
else
if
(isFairRegistry) {
121
// FairRegistry r1, r_in;
122
// std::string rins;
123
// fDefault.Get(k, r1);
124
// PROMPT("FairRegistry",r,r1);
125
// std::cin >> r_ins;
126
// r_in << r_ins;
127
// fResult.Set(k, r_in);
128
}
129
}
// loop over keys
130
return
fResult
;
131
}
EicRoot
blob
master
dbase
dbInterface
FairDbConfDialog.cxx
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:33
using
1.8.2 with
EIC GitHub integration