Gaudi Framework, version v23r9
Home
Generated: Thu Jul 18 2013
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
RootCnv
RootCnv
RootDataConnection.h
Go to the documentation of this file.
1
// $Id: RootDataConnection.h,v 1.9 2010-09-17 09:00:12 frankb Exp $
2
#ifndef GAUDIROOT_ROOTDATACONNECTION_H
3
#define GAUDIROOT_ROOTDATACONNECTION_H
4
5
// Framework include files
6
#include "
GaudiKernel/ClassID.h
"
7
#include "
GaudiUtils/IIODataManager.h
"
8
#include <
string
>
9
#include <
vector
>
10
#include <
map
>
11
#include <
set
>
12
13
#include "TFile.h"
14
#include "
RootCnv/RootRefs.h
"
15
16
// Forward declarations
17
class
TTree;
18
class
TClass;
19
class
TBranch;
20
class
TTreePerfStats;
21
22
class
MsgStream
;
23
class
IRegistry
;
24
class
DataObject
;
25
class
IIncidentSvc
;
26
27
/*
28
* Gaudi namespace declaration
29
*/
30
namespace
Gaudi
{
31
42
class
GAUDI_API
RootConnectionSetup
{
43
public
:
45
typedef
std::vector<std::string>
StringVec
;
46
protected
:
48
virtual
~
RootConnectionSetup
();
50
int
refCount
;
52
MsgStream
*
m_msgSvc
;
54
IIncidentSvc
*
m_incidentSvc
;
55
56
public
:
58
StringVec
cacheBranches
;
60
StringVec
vetoBranches
;
62
std::string
loadSection
;
64
int
cacheSize
;
66
int
learnEntries
;
67
69
RootConnectionSetup
();
71
void
addRef();
73
void
release();
74
76
static
long
setCompression(
const
std::string
& compression);
78
static
int
compression();
79
81
void
setMessageSvc(
MsgStream
*
m
);
83
MsgStream
&
msgSvc
()
const
{
return
*m_msgSvc; }
84
86
void
setIncidentSvc(
IIncidentSvc
*
m
);
88
IIncidentSvc
*
incidentSvc
()
const
{
return
m_incidentSvc; }
89
};
90
99
class
GAUDI_API
RootDataConnection
:
virtual
public
Gaudi::IDataConnection {
100
public
:
101
102
enum
{ ROOT_READ_ERROR = 0x2,
103
ROOT_OPEN_ERROR = 0x4
104
};
105
116
struct
ContainerSection
{
118
ContainerSection
() :
start
(-1), length(0) {}
120
ContainerSection
(
int
s
,
int
l
) :
start
(s), length(l) {}
122
ContainerSection
(
const
ContainerSection
&
s
) :
start
(s.
start
), length(s.length) {}
124
ContainerSection
&
operator=
(
const
ContainerSection
&
s
) {
start
=s.
start
;length=s.
length
;
return
*
this
;}
126
int
start
;
128
int
length
;
129
};
130
132
typedef
std::vector<std::string>
StringVec
;
134
typedef
std::vector<std::pair<std::string,std::string>
>
ParamMap
;
136
typedef
std::map<std::string,TTree*>
Sections
;
138
typedef
std::vector<ContainerSection>
ContainerSections
;
140
typedef
std::map<std::string,ContainerSections>
MergeSections
;
142
typedef
std::vector<RootRef>
LinkSections
;
144
typedef
std::set<const IInterface*>
Clients
;
145
147
MsgStream
&
msgSvc
()
const
{
return
m_setup->msgSvc(); }
148
149
150
protected
:
152
RootConnectionSetup
*
m_setup
;
154
TTreePerfStats*
m_statistics
;
156
TFile*
m_file
;
158
TTree *
m_refs
;
160
Sections
m_sections
;
162
StringVec
m_dbs
;
164
StringVec
m_conts
;
166
StringVec
m_links
;
168
StringVec
m_mergeFIDs
;
170
ParamMap
m_params
;
172
MergeSections
m_mergeSects
;
174
LinkSections
m_linkSects
;
176
Clients
m_clients
;
178
std::string
m_empty
;
179
181
const
std::string
&
empty
()
const
;
182
184
StatusCode
saveRefs();
185
186
public
:
196
class
Tool
{
197
protected
:
198
typedef
RootDataConnection::StringVec
StringVec
;
199
typedef
RootDataConnection::ParamMap
ParamMap
;
200
typedef
RootDataConnection::Sections
Sections
;
201
typedef
RootDataConnection::MergeSections
MergeSections
;
202
typedef
RootDataConnection::LinkSections
LinkSections
;
203
typedef
RootDataConnection::ContainerSection
ContainerSection
;
204
typedef
RootDataConnection::ContainerSections
ContainerSections
;
205
207
RootDataConnection
*
c
;
208
public
:
209
TTree*
refs
()
const
{
return
c
->m_refs; }
210
StringVec
&
dbs
()
const
{
return
c
->m_dbs; }
211
StringVec
&
conts
()
const
{
return
c
->m_conts; }
212
StringVec
&
links
()
const
{
return
c
->m_links; }
213
ParamMap
&
params
()
const
{
return
c
->m_params; }
214
MsgStream
&
msgSvc
()
const
{
return
c
->msgSvc(); }
215
const
std::string
&
name
()
const
{
return
c
->m_name; }
216
Sections
&
sections
()
const
{
return
c
->m_sections; }
217
LinkSections
&
linkSections
()
const
{
return
c
->m_linkSects; }
218
MergeSections
&
mergeSections
()
const
{
return
c
->m_mergeSects; }
219
221
virtual
~Tool
() {}
223
virtual
void
release
() {
delete
this
; }
225
virtual
TBranch* getBranch(
const
std::string
& section,
const
std::string
& n) = 0;
227
virtual
RootRef
poolRef
(
size_t
/* which */
)
const
{
return
RootRef
(); }
228
230
virtual
StatusCode
readRefs() = 0;
232
virtual
StatusCode
saveRefs() = 0;
234
virtual
int
loadRefs(
const
std::string
& section,
const
std::string
& cnt,
unsigned
long
entry,
RootObjectRefs
& refs) = 0;
235
} *m_tool;
236
friend
class
Tool
;
237
239
Tool
* makeTool();
240
241
public
:
242
244
RootDataConnection
(
const
IInterface
* own,
const
std::string
& nam,
RootConnectionSetup
* setup);
246
virtual
~
RootDataConnection
();
247
249
TFile*
file
()
const
{
return
m_file; }
251
virtual
bool
isConnected
()
const
{
return
m_file != 0; }
253
bool
isWritable
()
const
{
return
m_file != 0 && m_file->IsWritable(); }
255
Tool
*
tool
()
const
{
return
m_tool; }
257
const
MergeSections
&
mergeSections
()
const
{
return
m_mergeSects; }
259
const
StringVec
&
mergeFIDs
()
const
{
return
m_mergeFIDs; }
260
261
263
void
addClient(
const
IInterface
* client);
265
size_t
removeClient(
const
IInterface
* client);
267
bool
lookupClient(
const
IInterface
* client)
const
;
268
270
void
badWriteError(
const
std::string
&
msg
)
const
;
271
273
std::pair<const RootRef*,const ContainerSection*>
getMergeSection(
const
std::string
& container,
int
entry)
const
;
274
276
void
enableStatistics(
const
std::string
& section);
278
void
saveStatistics(
const
std::string
& statisticsFile);
279
281
int
loadObj(
const
std::string
& section,
const
std::string
& cnt,
unsigned
long
entry,
DataObject
*& pObj);
282
284
int
loadRefs(
const
std::string
& section,
const
std::string
& cnt,
unsigned
long
entry,
RootObjectRefs
& refs);
285
287
std::pair<int,unsigned long>
saveObj(
const
std::string
& section,
const
std::string
& cnt, TClass* cl,
DataObject
* pObj,
int
buff_siz,
int
split_lvl,
bool
fill_missing=
false
);
289
std::pair<int,unsigned long>
save(
const
std::string
& section,
const
std::string
& cnt, TClass* cl,
void
* pObj,
int
buff_siz,
int
split_lvl,
bool
fill_missing=
false
);
290
291
293
virtual
StatusCode
connectRead();
295
virtual
StatusCode
connectWrite(IoType typ);
297
virtual
StatusCode
disconnect();
299
virtual
StatusCode
read
(
void
*
const
,
size_t
) {
return
StatusCode::FAILURE
; }
301
virtual
StatusCode
write
(
const
void
*,
int
) {
return
StatusCode::FAILURE
; }
303
virtual
long
long
int
seek
(
long
long
int
,
int
) {
return
-1; }
304
306
TTree* getSection(
const
std::string
& sect,
bool
create=
false
);
307
309
TBranch* getBranch(
const
std::string
& section,
const
std::string
& branch_name)
310
{
return
m_tool->getBranch(section,branch_name); }
312
TBranch* getBranch(
const
std::string
& section,
const
std::string
& branch_name, TClass* cl,
void
* ptr,
int
buff_siz,
int
split_lvl);
313
315
void
makeRef(
IRegistry
* pA,
RootRef
& ref);
317
void
makeRef(
const
std::string
& name,
long
clid,
int
tech,
const
std::string
& db,
const
std::string
& cnt,
int
entry,
RootRef
& ref);
318
320
int
makeLink(
const
std::string
& p);
321
323
const
std::string
& getDb(
int
which
)
const
;
324
326
const
std::string
& getCont(
int
which
)
const
327
{
return
(which>=0)&&(size_t(which)<m_conts.size()) ? *(m_conts.begin()+
which
) :
empty
(); }
328
330
const
std::string
& getLink(
int
which
)
const
331
{
return
(which>=0)&&(size_t(which)<m_links.size()) ? *(m_links.begin()+
which
) :
empty
(); }
332
};
333
}
// End namespace Gaudi
334
#endif // GAUDIROOT_ROOTDATACONNECTION_H
Generated at Thu Jul 18 2013 12:18:05 for Gaudi Framework, version v23r9 by
Doxygen
version 1.8.2 written by
Dimitri van Heesch
, © 1997-2004