The Gaudi Framework
v26r1
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
RHistogramCnv.h
Go to the documentation of this file.
1
// $Id: RHistogramCnv.h,v 1.4 2007/01/08 17:16:02 mato Exp $
2
#ifndef ROOTHISTCNV_RHISTOGRAMCNV_H
3
#define ROOTHISTCNV_RHISTOGRAMCNV_H 1
4
5
// Include files
6
#include "
RConverter.h
"
7
#include "GaudiKernel/SmartIF.h"
8
#include "GaudiKernel/DataObject.h"
9
#include "GaudiKernel/IRegistry.h"
10
#include "GaudiKernel/IOpaqueAddress.h"
11
#include "GaudiKernel/HistogramBase.h"
12
#include "GaudiKernel/ObjectFactory.h"
13
#include "
RootObjAddress.h
"
14
#include "TArray.h"
15
#include <memory>
16
17
namespace
RootHistCnv {
18
31
template
<
typename
T,
typename
S,
typename
Q>
class
RHistogramCnv
:
public
RConverter
{
32
template
<
typename
CLASS>
struct
TTH
:
public
CLASS {
33
void
CopyH
(TObject& o) { CLASS::Copy(o); }
34
};
35
public
:
37
virtual
StatusCode
createObj
(
IOpaqueAddress
* pAddr,
DataObject
*& refpObj) {
38
refpObj = DataObjFactory::create(
objType
());
39
RootObjAddress
*r =
dynamic_cast<
RootObjAddress
*
>
(pAddr);
40
Q* h =
dynamic_cast<
Q*
>
(refpObj);
41
if
( r && h ) {
42
// Need to flip representation .... clumsy for the time being, because
43
// THXY constructor has no "generic" copy constructor
44
std::auto_ptr<T> p(
new
T());
45
S *
s
=
dynamic_cast<
S*
>
(r->
tObj
());
46
if
( s && p.get() ) {
47
TTH<S>
* casted = (
TTH<S>
*)s;
48
TArray* a =
dynamic_cast<
TArray*
>
(
s
);
49
casted->
CopyH
(*p);
50
if
( 0 != a ) {
51
p->Set(a->GetSize());
52
p->Reset();
53
p->Add(s);
54
h->adoptRepresentation(p.release());
55
return
StatusCode::SUCCESS
;
56
}
57
}
58
}
59
return
error
(
"Cannot create histogram - invalid address."
);
60
}
62
virtual
StatusCode
updateObj
(
IOpaqueAddress
*
/* pAddr */
,
DataObject
*
/* pObj */
) {
63
return
StatusCode::SUCCESS
;
64
}
66
virtual
TObject*
createPersistent
(
DataObject
* pObj) {
67
Q* h =
dynamic_cast<
Q*
>
(pObj);
68
if
( 0 != h ) {
69
T *r =
dynamic_cast<
T*
>
(h->representation());
70
if
( r ) {
71
T*
c
=
new
T();
72
TArray* a =
dynamic_cast<
TArray*
>
(r);
73
((
TTH<S>
*)r)->CopyH(*c);
74
if
( 0 != a ) {
75
c->Set(a->GetSize());
76
c->Reset();
77
c->Add(r);
78
c->SetName(pObj->
registry
()->
name
().c_str()+1);
79
return
c
;
80
}
81
}
82
}
83
error
(
"Histogram object is invalid!"
);
84
return
0;
85
}
87
static
const
CLID
&
classID
();
89
RHistogramCnv
(
ISvcLocator
* svc) :
RConverter
(
classID
(), svc) {}
90
virtual
~RHistogramCnv
() {}
91
};
92
}
// namespace RootHistCnv
93
#endif // ROOTHISTCNV_RHISTOGRAMCNV_H
RootHistCnv
src
RHistogramCnv.h
Generated on Mon Feb 16 2015 11:56:58 for The Gaudi Framework by
1.8.2