Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 2 // See the file tools.license for terms. 3 4 #ifndef tools_rroot_fac 5 #define tools_rroot_fac 6 7 #include "../sout" 8 #include "../S_STRING" 9 10 #include "branch_element" 11 #include "branch_object" 12 #include "leaf" 13 #include "basket" 14 #include "tree_index" 15 #include "stl_vector" 16 #include "dummy" 17 #include "obj_list" 18 #include "vector3" 19 #include "matrix" 20 21 #ifdef TOOLS_MEM 22 #include "../mem" 23 #endif 24 25 namespace tools { 26 namespace rroot { 27 28 class fac : public virtual ifac { 29 public: 30 TOOLS_SCLASS(tools::rroot::fac) 31 public: //ifac 32 virtual std::ostream& out() const {return m_ 33 virtual iro* create(const std::string& a_cla 34 //m_out << "tools::rroot::fac::create :" 35 // << " create object of class " << a 36 // << std::endl; 37 if(a_class=="TBranch") { 38 return new branch(m_out,*this); 39 } else if(a_class=="TBranchElement") { 40 return new branch_element(m_out,*this); 41 } else if(a_class=="TBranchObject") { 42 return new branch_object(m_out,*this); 43 44 } else if(a_class=="TLeafB") { 45 return new leaf<char>(m_out,*this); 46 47 } else if(a_class=="TLeafS") { 48 return new leaf<short>(m_out,*this); 49 50 } else if(a_class=="TLeafI") { 51 return new leaf<int>(m_out,*this); 52 53 } else if(a_class=="TLeafF") { 54 return new leaf<float>(m_out,*this); 55 56 } else if(a_class=="TLeafD") { 57 return new leaf<double>(m_out,*this); 58 59 } else if(a_class=="TLeafO") { 60 return new leaf<bool>(m_out,*this); 61 62 } else if(a_class=="TLeafC") { 63 return new leaf_string(m_out,*this); 64 65 } else if(a_class=="TLeafElement") { 66 return new leaf_element(m_out,*this); 67 68 } else if(a_class=="TLeafObject") { 69 return new leaf_object(m_out,*this); 70 71 } else if(a_class=="TBasket") { 72 return new basket(m_out); 73 74 // L.Duflot ATLAS file : 75 } else if(a_class=="TTreeIndex") { 76 return new tree_index(); 77 78 } else if(a_class=="TList") { 79 return new obj_list(*this); 80 } else if(a_class=="TVector3") { 81 return new vector3(); 82 } else if(a_class=="TMatrix") { 83 return new matrix(); 84 85 } else if(a_class=="TNamed") { 86 return new named(); 87 88 } else if(a_class=="vector<unsigned short> 89 return new stl_vector<unsigned short>(); 90 } else if(a_class=="vector<short>") { 91 return new stl_vector<short>(); 92 } else if(a_class=="vector<unsigned int>") 93 return new stl_vector<unsigned int>(); 94 } else if(a_class=="vector<int>") { 95 return new stl_vector<int>(); 96 } else if(a_class=="vector<float>") { 97 return new stl_vector<float>(); 98 } else if(a_class=="vector<double>") { 99 return new stl_vector<double>(); 100 101 } else if(a_class=="vector<unsigned long>" 102 return new stl_vector<uint64>(); //is it 103 104 } else if(a_class=="vector<string>") { 105 return new stl_vector_string(); 106 107 } else if(a_class=="vector<vector<unsigned 108 return new stl_vector_vector<unsigned sh 109 } else if(a_class=="vector<vector<short> > 110 return new stl_vector_vector<short>(); 111 } else if(a_class=="vector<vector<unsigned 112 return new stl_vector_vector<unsigned in 113 } else if(a_class=="vector<vector<int> >") 114 return new stl_vector_vector<int>(); 115 } else if(a_class=="vector<vector<float> > 116 return new stl_vector_vector<float>(); 117 } else if(a_class=="vector<vector<double> 118 return new stl_vector_vector<double>(); 119 120 } else if(a_class=="TBranchRef") { 121 return new dummy(); 122 123 } else { 124 m_out << "tools::rroot::fac::create :" 125 << " unknown class " << sou 126 << " Create a tools::rroot: 127 << std::endl; 128 return new dummy(); 129 } 130 } 131 public: 132 fac(std::ostream& a_out):m_out(a_out){ 133 #ifdef TOOLS_MEM 134 mem::increment(s_class().c_str()); 135 #endif 136 } 137 virtual ~fac(){ 138 #ifdef TOOLS_MEM 139 mem::decrement(s_class().c_str()); 140 #endif 141 } 142 public: 143 fac(const fac& a_from):ifac(a_from),m_out(a_ 144 #ifdef TOOLS_MEM 145 mem::increment(s_class().c_str()); 146 #endif 147 } 148 fac& operator=(const fac&){return *this;} 149 protected: 150 /* 151 branch* arg_branch(const args& a_args) { 152 void* p = ifac::find_args(a_args,ifac::arg 153 if(!p) { 154 m_out << "tools::rroot::fac::arg_branch 155 << " branch not found in ar 156 << std::endl; 157 return 0; 158 } 159 return (branch*)p; 160 } 161 */ 162 protected: 163 std::ostream& m_out; 164 }; 165 166 }} 167 168 #endif