Class Reference for E1039 Core & Analysis Software
Home page
Related Pages
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
getClass.h
Go to the documentation of this file.
1
#ifndef GETCLASS_H__
2
#define GETCLASS_H__
3
4
#include "
PHNodeIterator.h
"
5
#include "
PHIODataNode.h
"
6
#include "
PHDataNode.h
"
7
#include "
PHNode.h
"
8
9
#include <TObject.h>
10
11
#include <string>
12
13
class
PHCompositeNode
;
14
15
namespace
findNode
16
{
17
template
<
class
T>
18
T*
getClass
(
PHCompositeNode
*top,
const
std::string &name)
19
{
20
PHNodeIterator
iter(top);
21
PHNode
*FoundNode = iter.
findFirst
(name.c_str());
// returns pointer to PHNode
22
if
(!FoundNode)
23
{
24
return
NULL
;
25
}
26
// first test if it is a PHDataNode
27
PHDataNode<T>
*DNode =
dynamic_cast<
PHDataNode<T>
*
>
(FoundNode);
28
if
(DNode)
29
{
30
T*
object
=
dynamic_cast<
T*
>
(DNode->
getData
());
31
if
(
object
)
32
{
33
return
object;
34
}
35
}
36
37
// We make a static cast for PHIODataNode<TObject> since all
38
// PHIODataNodes have to contain a TObject (otherwise it cannot be
39
// written out and it should be a PHDataNode. dynamic cast does not
40
// work (see some explanation in PHTypedNodeIterator.h)
41
42
PHIODataNode<TObject>
*IONode =
static_cast<
PHIODataNode<TObject>
*
>
(FoundNode);
43
if
(IONode)
44
{
45
T*
object
=
dynamic_cast<
T*
>
(IONode->
getData
());
46
if
(!
object
)
47
{
48
return
NULL
;
49
}
50
else
51
{
52
return
object;
53
}
54
}
55
56
return
NULL
;
57
}
58
}
59
60
#endif
/* GETCLASS_H */
PHNodeIterator::findFirst
PHNode * findFirst(const std::string &, const std::string &)
Definition:
PHNodeIterator.cc:50
PHDataNode
Definition:
PHDataNode.h:13
NULL
#define NULL
Definition:
Pdb.h:9
PHDataNode.h
PHDataNode::getData
T * getData()
Definition:
PHDataNode.h:21
PHCompositeNode
Definition:
PHCompositeNode.h:14
PHIODataNode.h
PHIODataNode
Definition:
PHIODataNode.h:18
findNode::getClass
T * getClass(PHCompositeNode *top, const std::string &name)
Definition:
getClass.h:18
PHNode.h
PHNodeIterator
Definition:
PHNodeIterator.h:14
PHNode
Definition:
PHNode.h:14
PHNodeIterator.h
e1039-core
framework
phool
getClass.h
Built by
Haiwang Yu
. updated:
Wed May 26 2021 21:44:02
using
1.8.5 with
SeaQuest GitHub integration