Gaudi Framework, version v24r2
Home
Generated: Wed Dec 4 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
RootHistCnv
src
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 "
RootObjAddress.h
"
13
#include "TArray.h"
14
#include <
memory
>
15
16
namespace
RootHistCnv {
17
30
template
<
typename
T,
typename
S,
typename
Q>
class
RHistogramCnv
:
public
RConverter
{
31
template
<
typename
CLASS>
struct
TTH
:
public
CLASS {
32
void
CopyH
(TObject& o) { CLASS::Copy(o); }
33
};
34
public
:
36
virtual
StatusCode
createObj
(
IOpaqueAddress
* pAddr,
DataObject
*& refpObj) {
37
refpObj = ROOT::Reflex::PluginService::CreateWithId<DataObject*>(
objType
());
38
RootObjAddress
*r =
dynamic_cast<
RootObjAddress
*
>
(pAddr);
39
Q* h =
dynamic_cast<
Q*
>
(refpObj);
40
if
( r && h ) {
41
// Need to flip representation .... clumsy for the time being, because
42
// THXY constructor has no "generic" copy constructor
43
std::auto_ptr<T>
p(
new
T());
44
S
*
s
=
dynamic_cast<
S
*
>
(r->tObj());
45
if
( s && p.
get
() ) {
46
TTH<S>
* casted = (
TTH<S>
*)s;
47
TArray* a =
dynamic_cast<
TArray*
>
(
s
);
48
casted->
CopyH
(*p);
49
if
( 0 != a ) {
50
p->Set(a->GetSize());
51
p->Reset();
52
p->Add(s);
53
h->adoptRepresentation(p.
release
());
54
return
StatusCode::SUCCESS
;
55
}
56
}
57
}
58
return
error
(
"Cannot create histogram - invalid address."
);
59
}
61
virtual
StatusCode
updateObj
(
IOpaqueAddress
*
/* pAddr */
,
DataObject
*
/* pObj */
) {
62
return
StatusCode::SUCCESS
;
63
}
65
virtual
TObject*
createPersistent
(
DataObject
* pObj) {
66
Q* h =
dynamic_cast<
Q*
>
(pObj);
67
if
( 0 != h ) {
68
T *r =
dynamic_cast<
T*
>
(h->representation());
69
if
( r ) {
70
T*
c
=
new
T();
71
TArray* a =
dynamic_cast<
TArray*
>
(r);
72
((
TTH<S>
*)r)->CopyH(*c);
73
if
( 0 != a ) {
74
c->Set(a->GetSize());
75
c->Reset();
76
c->Add(r);
77
c->SetName(pObj->
registry
()->
name
().c_str()+1);
78
return
c
;
79
}
80
}
81
}
82
error
(
"Histogram object is invalid!"
);
83
return
0;
84
}
86
static
const
CLID
&
classID
();
88
RHistogramCnv
(
ISvcLocator
* svc) :
RConverter
(
classID
(), svc) {}
89
virtual
~RHistogramCnv
() {}
90
};
91
}
// namespace RootHistCnv
92
#endif // ROOTHISTCNV_RHISTOGRAMCNV_H
Generated at Wed Dec 4 2013 14:33:12 for Gaudi Framework, version v24r2 by
Doxygen
version 1.8.2 written by
Dimitri van Heesch
, © 1997-2004