ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHIODataNode.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHIODataNode.h
1 #ifndef PHOOL_PHIODATANODE_H
2 #define PHOOL_PHIODATANODE_H
3 
4 // Declaration of class PHIODataNode which can hold persistent data
5 // Author: Matthias Messer
6 
7 #include "PHDataNode.h"
8 #include "PHIOManager.h"
9 #include "PHNodeIOManager.h"
10 #include "PHTypedNodeIterator.h"
11 #include "phooldefs.h"
12 
13 #include <TObject.h>
14 
15 #include <string>
16 
17 template <typename T>
18 class PHIODataNode : public PHDataNode<T>
19 {
20  friend class PHNodeIOManager;
21 
22  public:
23  T *operator*() { return this->getData(); }
24  PHIODataNode(T *, const std::string &);
25  PHIODataNode(T *, const std::string &, const std::string &);
26  virtual ~PHIODataNode() {}
28  void BufferSize(int size) {buffersize = size;}
30 
31  protected:
32  virtual bool write(PHIOManager *, const std::string & = "");
33  PHIODataNode() = delete;
36 };
37 
38 template <class T>
39 PHIODataNode<T>::PHIODataNode(T *d, const std::string &name)
40  : PHDataNode<T>(d, name)
41  , buffersize(32000)
42  , splitlevel(99)
43 {
44  this->type = "PHIODataNode";
45  TObject *TO = static_cast<TObject *>(d);
46  this->objectclass = TO->GetName();
47 }
48 
49 template <class T>
50 PHIODataNode<T>::PHIODataNode(T *d, const std::string &name,
51  const std::string &objtype)
52  : PHDataNode<T>(d, name, objtype)
53  , buffersize(32000)
54  , splitlevel(99)
55 {
56  this->type = "PHIODataNode";
57  TObject *TO = static_cast<TObject *>(d);
58  this->objectclass = TO->GetName();
59 }
60 
61 template <class T>
62 bool PHIODataNode<T>::write(PHIOManager *IOManager, const std::string &path)
63 {
64  if (this->persistent)
65  {
66  PHNodeIOManager *np = dynamic_cast<PHNodeIOManager *>(IOManager);
67  if (np)
68  {
69  std::string newPath = path + phooldefs::branchpathdelim + this->name;
70  bool bret = false;
71  if (dynamic_cast<TObject *>(this->data.data))
72  {
73  bret = np->write(&(this->data.tobj), newPath, buffersize, splitlevel);
74  }
75  return bret;
76  }
77  }
78  return true;
79 }
80 
81 #endif /* PHOOL_PHIODATANODE_H */