Class Reference for E1039 Core & Analysis Software
PHDataNodeIterator.h
Go to the documentation of this file.
1 #ifndef __PHDATANODEITERATOR_H__
2 #define __PHDATANODEITERATOR_H__
3 
4 #include "PHIODataNode.h"
5 #include "PHNodeIterator.h"
6 #include "PHIODataNode.h"
7 #include <cstddef>
8 
20 {
21 public:
22 
25 
27  virtual ~PHDataNodeIterator(){}
28 
36  template <class T>
38  const char* name);
39 
46  template <class T>
47  PHBoolean AddIODataNode(T* data, const char* name);
48 
49 };
50 
51 
52 inline
54  : PHNodeIterator(node)
55 {
56 }
57 
58 
59 template <class T>
62  const char* name)
63 {
64  // TODO: also check that "name" is not a null string!
65  if (!name)
66  {
67  return 0;
68  }
69  // Can't do dynamic_cast here; it fails if node was created as
70  // PHIODataNode<X> instead of PHIODataNode<T>, even if T is a
71  // derived class of X!
72  // In general, T -> X does not imply A<T> -> A<X>.
73  // ("->" denotes "derives from", and "A" is any template class)
74  node = static_cast<PHIODataNode<T>*>(findFirst("PHIODataNode",
75  name));
76  return node;
77 }
78 
79 
80 template <class T>
82 PHDataNodeIterator::AddIODataNode(T* data, const char* name)
83 {
84  // TODO: also check that "name" is not a null string!
85  if (!name)
86  {
87  return False;
88  }
89  // For IODataNode, ought to check (if possible) that T derives
90  // from TObject. Will typeid() give us this info?
91 
92  PHIODataNode<T>* n = new PHIODataNode<T>(data, name);
93  if (!n)
94  {
95  return False; // problem creating node?
96  }
97  return addNode(n);
98 }
99 
100 #endif /* __PHDATANODEITERATOR_H__ */
PHDataNodeIterator(PHCompositeNode *node)
Constructor.
virtual ~PHDataNodeIterator()
Destructor.
PHBoolean AddIODataNode(T *data, const char *name)
PHIODataNode< T > * FindIODataNode(PHIODataNode< T > *node, const char *name)
PHBoolean addNode(PHNode *)
PHNode * findFirst(const std::string &, const std::string &)
int PHBoolean
Definition: phool.h:13
static const int False
Definition: phool.h:9