ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHDataNodeIterator.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHDataNodeIterator.h
1 #ifndef PHOOL_PHDATANODEITERATOR_H
2 #define PHOOL_PHDATANODEITERATOR_H
3 
4 #include "PHIODataNode.h"
5 #include "PHNodeIterator.h"
6 
7 #include <cstddef>
8 
20 {
21  public:
24 
26  ~PHDataNodeIterator() override {}
34  template <class T>
36  const char* name);
37 
44  template <class T>
45  PHBoolean AddIODataNode(T* data, const char* name);
46 };
47 
49  : PHNodeIterator(node)
50 {
51 }
52 
53 template <class T>
56  const char* name)
57 {
58  // TODO: also check that "name" is not a null string!
59  if (!name)
60  {
61  return 0;
62  }
63  // Can't do dynamic_cast here; it fails if node was created as
64  // PHIODataNode<X> instead of PHIODataNode<T>, even if T is a
65  // derived class of X!
66  // In general, T -> X does not imply A<T> -> A<X>.
67  // ("->" denotes "derives from", and "A" is any template class)
68  node = static_cast<PHIODataNode<T>*>(findFirst("PHIODataNode",
69  name));
70  return node;
71 }
72 
73 template <class T>
74 PHBoolean
76 {
77  // TODO: also check that "name" is not a null string!
78  if (!name)
79  {
80  return false;
81  }
82  // For IODataNode, ought to check (if possible) that T derives
83  // from TObject. Will typeid() give us this info?
84 
86  if (!n)
87  {
88  return false; // problem creating node?
89  }
90  return addNode(n);
91 }
92 
93 #endif