File indexing completed on 2025-08-05 08:16:19
0001 #ifndef PHOOL_PHIODATANODE_H
0002 #define PHOOL_PHIODATANODE_H
0003
0004
0005
0006
0007 #include "PHDataNode.h"
0008 #include "PHIOManager.h"
0009 #include "PHNodeIOManager.h"
0010 #include "PHTypedNodeIterator.h"
0011 #include "phooldefs.h"
0012
0013 #include <TObject.h>
0014
0015 #include <string>
0016
0017 template <typename T>
0018 class PHIODataNode : public PHDataNode<T>
0019 {
0020 friend class PHNodeIOManager;
0021
0022 public:
0023 T *operator*() { return this->getData(); }
0024 PHIODataNode(T *, const std::string &);
0025 PHIODataNode(T *, const std::string &, const std::string &);
0026 virtual ~PHIODataNode() = default;
0027 typedef PHTypedNodeIterator<T> iterator;
0028 void BufferSize(int size) { buffersize = size; }
0029 void SplitLevel(int split) { splitlevel = split; }
0030
0031 protected:
0032 bool write(PHIOManager *, const std::string & = "") override;
0033 PHIODataNode() = delete;
0034 int buffersize{32000};
0035 int splitlevel{0};
0036 };
0037
0038 template <class T>
0039 PHIODataNode<T>::PHIODataNode(T *d, const std::string &n)
0040 : PHDataNode<T>(d, n)
0041 {
0042 this->type = "PHIODataNode";
0043 TObject *TO = static_cast<TObject *>(d);
0044 this->objectclass = TO->GetName();
0045 }
0046
0047 template <class T>
0048 PHIODataNode<T>::PHIODataNode(T *d, const std::string &n,
0049 const std::string &objtype)
0050 : PHDataNode<T>(d, n, objtype)
0051 {
0052 this->type = "PHIODataNode";
0053 TObject *TO = static_cast<TObject *>(d);
0054 this->objectclass = TO->GetName();
0055 }
0056
0057 template <class T>
0058 bool PHIODataNode<T>::write(PHIOManager *IOManager, const std::string &path)
0059 {
0060 if (this->persistent)
0061 {
0062 PHNodeIOManager *np = dynamic_cast<PHNodeIOManager *>(IOManager);
0063 if (np)
0064 {
0065 std::string newPath = path + phooldefs::branchpathdelim + this->name;
0066 bool bret = false;
0067 if (dynamic_cast<TObject *>(this->data.data))
0068 {
0069 bret = np->write(&(this->data.tobj), newPath, buffersize, splitlevel);
0070 }
0071 return bret;
0072 }
0073 }
0074 return true;
0075 }
0076
0077 #endif